predictive_check: JAGS analysis posterior predictive checks

Description Usage Arguments Value See Also Examples

Description

Calculate posterior predictive check p-value for a JAGS analysis

Usage

1
2
3
predictive_check(object, parm = "discrepancy",
  model_id = default_model_id(object), derived_code = NULL,
  level = "current", estimate = "current", ...)

Arguments

object

a jags_analysis object.

parm

a character vector specifying the discrepancy derived parameters (default = "discrepancy").

model_id

a count or string specifying the jags model to select.

derived_code

a character scalar defining a block in the JAGS dialect of the BUGS language that defines the discrepancy(s).

level

a numeric scalar specifying the significance level or a character scalar specifying which mode the level should be taken from. By default the level is as currently specified by opts_jagr in the global options.

estimate

a character scalar indicating whether the point estimate should be the "mean" or the "median". By default the estimate is as currently defined by opts_jagr in the global options.

...

further arguments passed to or from other methods.

Value

a coef table of the posterior predictive check p-values(s)

See Also

jags_model, jags_analysis ,predict.jags_analysis and coef.jags_analysis

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
## Not run: 
model1 <- jags_model("model {
alpha ~ dnorm(0, 50^-2) 
beta ~ dnorm(0, 10^-2)
sigma ~ dunif(0, 10)

for(i in 1:length(Volume)) { 
  eMu[i] <- alpha + beta * Girth[i]
  Volume[i] ~ dnorm(eMu[i], sigma^-2)
} 
}",
derived_code = "data {
for(i in 1:length(Volume)) { 
  prediction[i] <- alpha + beta * Girth[i]
  
  simulated[i] ~ dnorm(prediction[i], sigma^-2)
  
  D_observed[i] <- log(dnorm(Volume[i], prediction[i], sigma^-2))
  D_simulated[i] <- log(dnorm(simulated[i], prediction[i], sigma^-2))
}
discrepancy <- sum(D_observed) - sum(D_simulated)

}",
select_data = c("Volume", "Girth*"))

data(trees)
analysis1 <- jags_analysis(model1, data = trees)
predictive_check(analysis1)

## End(Not run)

poissonconsulting/jaggernaut documentation built on Feb. 18, 2021, 11:10 p.m.