View source: R/convenience-functions.R
me_diag | R Documentation |
Visual diagnostics for spatial measurement error models.
me_diag(
fit,
varname,
shape,
probs = c(0.025, 0.975),
plot = TRUE,
mc_style = c("scatter", "hist"),
size = 0.25,
index = 0,
style = c("W", "B"),
w = shape2mat(shape, match.arg(style), quiet = TRUE),
binwidth = function(x) 0.5 * sd(x)
)
fit |
A |
varname |
Name of the modeled variable (a character string, as it appears in the model formula). |
shape |
An object of class |
probs |
Lower and upper quantiles of the credible interval to plot. |
plot |
If |
mc_style |
Character string indicating how to plot the Moran coefficient for the delta values: if |
size |
Size of points and lines, passed to |
index |
Integer value; use this if you wish to identify observations with the largest |
style |
Style of connectivity matrix; if |
w |
An optional spatial connectivity matrix; if not provided, one will be created using |
binwidth |
A function with a single argument that will be passed to the |
A grid of spatial diagnostic plots for measurement error models comparing the raw observations to the posterior distribution of the true values. Includes a point-interval plot of raw values and modeled values; a Moran scatter plot for delta = z - x
where z
are the survey estimates and x
are the modeled values; and a map of the delta values (take at their posterior means).
Donegan, Connor and Chun, Yongwan and Griffith, Daniel A. (2021). “Modeling community health with areal data: Bayesian inference with survey standard errors and spatial structure.” Int. J. Env. Res. and Public Health 18 (13): 6856. DOI: 10.3390/ijerph18136856 Data and code: https://github.com/ConnorDonegan/survey-HBM.
sp_diag
, moran_plot
, mc
, aple
library(sf)
data(georgia)
## binary adjacency matrix
A <- shape2mat(georgia, "B")
## prepare data for the CAR model, using WCAR specification
cars <- prep_car_data(A, style = "WCAR")
## provide list of data for the measurement error model
ME <- prep_me_data(se = data.frame(college = georgia$college.se),
car_parts = cars)
## sample from the prior probability model only, including the ME model
fit <- stan_glm(log(rate.male) ~ college,
ME = ME,
data = georgia,
prior_only = TRUE,
iter = 1e3, # for speed only
chains = 2, # for speed only
refresh = 0 # silence some printing
)
## see ME diagnostics
me_diag(fit, "college", georgia)
## see index values for the largest (absolute) delta values
## (differences between raw estimate and the posterior mean)
me_diag(fit, "college", georgia, index = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.