Prepares the list of data required for geostan's (spatial) measurement error models. Given a data frame of standard errors and any optional arguments, the function returns a list with all required data for the models, filling in missing elements with default values.

  logit = rep(FALSE, times = ncol(se)),
  bounds = c(-Inf, Inf)



Data frame of standard errors; column names must match (exactly) the variable names used in the model formula.


A list of data required for spatial CAR models, as created by prep_car_data; optional. If omitted, the measurement error model will be a non-spatial Student's t model.


A named list of prior distributions (see priors). If none are provided, default priors will be assigned. The list of priors may include the following parameters:


If using a non-spatial ME model, the degrees of freedom (df) for the Student's t model is assigned a gamma prior with default parameters of gamma2(alpha = 3, beta = 0.2). Provide values for each covariate in se, listing the values in the same order as the columns of se.


The prior for the location parameter (mu) is a normal (Gaussian) distribution (the default being normal(location = 0, scale = 100)). To adjust the prior distributions, provide values for each covariate in se, listing the values in the same order as the columns of se.


The prior for the scale parameters is Student's t, and the default parameters are student_t(df = 10, location = 0, scale = 40). To adjust, provide values for each covariate in se, listing the values in the same order as the columns of se.


The CAR model, if used, has a spatial autocorrelation parameter, rho, which is assigned a uniform prior distribution. You must specify values that are within the permissible range of values for rho; these are automatically printed to the console by the prep_car_data function.


Optional vector of logical values (TRUE, FALSE) indicating if the latent variable should be logit-transformed. Only use for rates. This keeps rates between zero and one and may improve modeling of skewed variables (e.g., the poverty rate).


Rarely needed; an optional numeric vector of length two providing the upper and lower bounds, respectively, of the variables (e.g., a magnitudes must be greater than 0). If not provided, they will be set to c(-Inf, Inf) (i.e., unbounded).


A list of data as required for (spatial) ME models. Missing arguments will be filled in with default values, including prior distributions.

See also



## for a non-spatial prior model for two covariates
se <- data.frame(ICE = georgia$,
                 college = georgia$
ME <- prep_me_data(se)

## see default priors

## set prior for the scale parameters
ME <- prep_me_data(se,
                   prior = list(scale = student_t(df = c(10, 10),
                                                  location = c(0, 0),
                                                  scale = c(20, 20))))

## for a spatial prior model (often recommended)
A <- shape2mat(georgia, "B")
cars <- prep_car_data(A)
ME <- prep_me_data(se,
                   car_parts = cars)