Extract posterior summaries of random effects
Usage
getDiag(
inla_mod,
field = c("space", "time", "spacetime")[1],
CI = 0.95,
draws = NULL,
nsim = 1000,
...
)
Arguments
- inla_mod
output from
smoothDirect
orsmoothCluster
- field
which random effects to plot. It can be one of the following: space, time, and spacetime.
- CI
Desired level of credible intervals
- draws
Posterior samples drawn from the fitted model. This argument allows the previously sampled draws (by setting save.draws to be TRUE) be used in new aggregation tasks.
- nsim
number of simulations, only applicable for the cluster-level model space-time interaction terms when random slopes are included.
- ...
Unused arguments, for users with fitted object from the package before v1.0.0, arguments including Amat, year_label, and year_range can still be specified manually.
Examples
if (FALSE) { # \dontrun{
data(DemoMap)
years <- levels(DemoData[[1]]$time)
# obtain direct estimates
data <- getDirectList(births = DemoData,
years = years,
regionVar = "region", timeVar = "time",
clusterVar = "~clustid+id",
ageVar = "age", weightsVar = "weights",
geo.recode = NULL)
# obtain direct estimates
data_multi <- getDirectList(births = DemoData, years = years,
regionVar = "region", timeVar = "time", clusterVar = "~clustid+id",
ageVar = "age", weightsVar = "weights", geo.recode = NULL)
data <- aggregateSurvey(data_multi)
# national model
years.all <- c(years, "15-19")
fit1 <- smoothDirect(data = data, geo = DemoMap$geo, Amat = DemoMap$Amat,
year_label = years.all, year_range = c(1985, 2019),
rw = 2, is.yearly=FALSE, m = 5)
random.time <- getDiag(fit1, field = "time")
random.space <- getDiag(fit1, field = "space")
random.spacetime <- getDiag(fit1, field = "spacetime")
} # }