Skip to contents

Compares observed counts with fitted Poisson means, returns Pearson residuals, and tests them for residual spatial autocorrelation with Moran's I. A non-significant Moran's I indicates the spatial random effect has absorbed the spatial structure.

Usage

model_check(object, pred = NULL, nsim = 999, plot = TRUE)

Arguments

object

a fitted "SDALGCP2" object.

pred

a discrete prediction from predict(object, "discrete"); if NULL one is computed with the fitting MCMC controls.

nsim

permutations for the Moran's I p-value.

plot

logical; draw the observed-vs-fitted scatter.

Value

invisibly, a list with fitted, residuals and moran.

Examples

# \donttest{
data(sdalgcp_data)
fit <- sdalgcp(cases ~ x1 + offset(log(pop)), data = sdalgcp_data,
               control = sdalgcp_control(n_sim = 2000, burnin = 500, thin = 5,
                                         reanchor = 0))
chk <- model_check(fit, plot = FALSE)
chk$moran            # residual Moran's I and its permutation p-value
#> $I
#> [1] -0.1469605
#> 
#> $expected
#> [1] -0.01587302
#> 
#> $p_value
#> [1] 0.987
#> 
# }