mec {mcmcsae} | R Documentation |
Create a model component object for a regression (fixed effects) component in the linear predictor with measurement errors in quantitative covariates
Description
This function is intended to be used on the right hand side of the
formula
argument to create_sampler
or
generate_data
. It creates an additive regression term in the
model's linear predictor. Covariates are assumed to be measured subject
to normally distributed errors with zero mean and variance specified using
the formula
or V
arguments. Note that this means that formula
should only contain quantitative variables, and no intercept.
By default, the prior for the regression
coefficients is improper uniform. A proper normal prior can be set up
using function pr_normal
, and passed to argument prior
.
It should be noted that pr_normal
expects a precision matrix
as input for its second argument, and that the prior variance (matrix) is
taken to be the inverse of this precision matrix, where in case the
model's family is "gaussian"
this matrix is additionally
multiplied by the residual scalar variance parameter sigma_^2
.
Usage
mec(
formula = ~1,
sparse = NULL,
X = NULL,
V = NULL,
prior = NULL,
Q0 = NULL,
b0 = NULL,
R = NULL,
r = NULL,
S = NULL,
s = NULL,
lower = NULL,
upper = NULL,
name = "",
debug = FALSE
)
Arguments
formula |
a formula specifying the predictors subject to measurement error
and possibly their variances as well. In the latter case the formula syntax
|
sparse |
whether the model matrix associated with |
X |
a (possibly sparse) design matrix can be specified directly, as an
alternative to the creation of one based on |
V |
measurement error variance; can contain zeros |
prior |
prior specification for the regression coefficients. Currently only
normal priors are supported, specified using function |
Q0 |
prior precision matrix for the regression effects. The default is a
zero matrix corresponding to a noninformative improper prior.
It can be specified as a scalar value, as a numeric vector of appropriate
length, or as a matrix object. DEPRECATED, please use argument |
b0 |
prior mean for the regression effect. Defaults to a zero vector.
It can be specified as a scalar value or as a numeric vector of
appropriate length. DEPRECATED, please use argument |
R |
optional constraint matrix for equality restrictions R'x = r where
|
r |
right hand side for the equality constraints. |
S |
optional constraint matrix for inequality constraints S'x >= s where x is the vector of regression effects. |
s |
right hand side for the inequality constraints. |
lower |
as an alternative to |
upper |
as an alternative to |
name |
the name of the model component. This name is used in the output of the
MCMC simulation function |
debug |
if |
Value
An object with precomputed quantities and functions for sampling from prior or conditional posterior distributions for this model component. Intended for internal use by other package functions.
References
L.M. Ybarra and S.L. Lohr (2008). Small area estimation when auxiliary information is measured with error. Biometrika 95(4), 919-931.
S. Arima, G.S. Datta and B. Liseo (2015). Bayesian estimators for small area models when auxiliary information is measured with error. Scandinavian Journal of Statistics 42(2), 518-529.
Examples
# example of Ybarra and Lohr (2008)
m <- 50
X <- rnorm(m, mean=5, sd=3) # true covariate values
v <- rnorm(m, sd=2)
theta <- 1 + 3*X + v # true values
psi <- rgamma(m, shape=4.5, scale=2)
e <- rnorm(m, sd=sqrt(psi)) # sampling error
y <- theta + e # direct estimates
C <- c(rep(3, 10), rep(0, 40)) # measurement error for first 10 values
W <- X + rnorm(m, sd=sqrt(C)) # covariate subject to measurement error
# fit Ybarra-Lohr model
sampler <- create_sampler(
y ~ 1 + mec(~ 0 + W, V=C) + gen(factor=~local_),
Q0=1/psi, sigma.fixed=TRUE, linpred="fitted"
)
sim <- MCMCsim(sampler, n.iter=800, n.chain=2, store.all=TRUE, verbose=FALSE)
(summ <- summary(sim))
plot(X, W, xlab="true X", ylab="inferred X")
points(X, summ$mec2_X[, "Mean"], col="green")
abline(0, 1, col="red")
legend("topleft", legend=c("prior mean", "posterior mean"), col=c("black", "green"), pch=c(1,1))