Learn R Programming

SUMMER (version 1.3.0)

getDiag: Extract posterior summaries of random effects

Description

Extract posterior summaries of random effects

Usage

getDiag(
  inla_mod,
  field = c("space", "time", "spacetime")[1],
  CI = 0.95,
  draws = NULL,
  ...
)

Value

List of diagnostic plots

Arguments

inla_mod

output from smoothDirect

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.

...

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.

Author

Zehang Richard Li

Examples

Run this code
if (FALSE) {
  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")
}

Run the code above in your browser using DataLab