View source: R/simulate_residual.r
simulate_residual | R Documentation |
greta_mcmc_list
to a DHARMa
objectCreate a DHARMa
object from a fitted greta model.
simulate_residual(object, y, linpred, nsim = 10, integerResponse = FALSE)
object |
A greta_mcmc_list object obtained from the greta::mcmc function |
y |
A greta array of the response variable, see example |
linpred |
A greta array of the expected value of y (typically the linear predictor in GLMM) |
nsim |
A numeric, the number of posterior simulation to draw, default is 10 |
integerResponse |
A logical, whether the response variable is of integer type (binomial or poisson distribution). If TRUE, noise will be added to the residuals to maintain uniform expectations. Default is FALSE. |
For hierarchical models the linear predictor can be set conditional to the random terms, or unconditional to them. Best practice seems to be to define the linear predictor (the predictions) unconditional from the random effects (see DHARMa issues 43).
DHARMa objects come with many methods to check (among other): model miss-fit, overdispersion, spatial or temporal autocorrelation ... Check the DHARMa
manual for examples and options.
A DHARMa object that allows plenty of model checks methods from the DHARMa package.
## Not run: x <- runif(100, -2, 2) y <- rnorm(100, 1 + 2 * x, 1) y <- as_data(y) intercept <- normal(0, 1) slope <- normal(0, 1) linpred <- intercept + slope * x sd_res <- cauchy(0, 1, truncation = c(0, 50)) distribution(y) <- normal(linpred, sd_res) m <- model(intercept, slope, sd_res) d <- mcmc(m) sims <- simulate_residual(d, y, linpred) plot(sims) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.