Description Usage Arguments Details Value Author(s) References See Also Examples
Simulates or predicts missing values from their predictive distribution given the observed data under a normal model with fixed parameters.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | impNorm(obj, ...)
## Default S3 method:
impNorm(obj, x = NULL, intercept = TRUE, param,
seeds = NULL, method = "random", ...)
## S3 method for class 'formula'
impNorm(formula, data, param,
seeds = NULL, method = "random", ...)
## S3 method for class 'norm'
impNorm(obj, param = obj$param, seeds = NULL,
method = "random", ...)
|
obj |
an object used to select a method. It may be |
x |
a numeric matrix, vector or data frame of covariates to be
used as predictors for |
intercept |
if |
formula |
an object of class |
data |
an optional data frame, list or environment (or object
coercible by |
param |
assumed values for the model
parameters. This must be a list with two named components,
|
seeds |
two integers to initialize the random number generator; see DETAILS. |
method |
if |
... |
values to be passed to the methods. |
This function is used primarily in conjunction with
mcmcNorm
to draw multiple imputations by the
multiple-chain method. In those instances, the simplest way to call
impNorm
is to provide an object of class "norm"
as its
first argument, where that object is the result of a call to
mcmcNorm
. The parameter values stored in that object will
then be passed to impNorm
automatically.
Alternatively, one may call impNorm
by providing as the first
argument y
, a vector or matrix of data to be modeled as
normal, and an optional vector or matrix of predictors x
.
Missing values NA
are allowed in y
but not in x
.
A third way to call impNorm
is to provide
formula
, a formula for a (typically
multivariate) linear regression model in the manner expected by
lm
. A formula is given as y ~ model
, where
y
is either a single numeric variable or a matrix of numeric
variables bound together with the function cbind
. The
right-hand side of the formula (everything to the right of ~
) is a
linear predictor, a series of terms separated by operators +
,
:
or *
to specify main effects and
interactions. Factors are allowed on the right-hand side and will
enter the model as contrasts among the levels
. The
intercept term 1
is included by default; to remove the
intercept, use -1
.
norm2
functions use their own internal random number generator which
is seeded by two integers, for example, seeds=c(123,456)
,
which allows results to be reproduced in the future. If
seeds=NULL
then
the function will seed itself with two random
integers from R. Therefore, results can also be made reproducible by
calling set.seed
beforehand and taking seeds=NULL
.
a data matrix resembling the original data y
, but
with NA
's replaced by simulated values or predictions.
Joe Schafer Joseph.L.Schafer@census.gov
Schafer, J.L. (1997) Analysis of Incomplete Multivariate
Data. London: Chapman & Hall/CRC Press.
For more information about this function and other functions in
the norm2
package, see User's Guide for norm2
in the library subdirectory doc
.
1 2 3 4 5 6 7 8 9 10 11 12 | ## run EM for marijuana data with ridge prior
data(marijuana)
emResult <- emNorm(marijuana, prior="ridge", prior.df=0.5)
## generate 25 multiple imputations by running 25 chains
## of 100 iterations each, starting each chain at the
## posterior mode
set.seed(456)
imp.list <- as.list(NULL)
for(m in 1:25){
mcmcResult <- mcmcNorm(emResult, iter=100)
imp.list[[m]] <- impNorm(mcmcResult)}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.