After fitting a log-linear model with cvam
,
the fitted model object may be passed to this function, along with a
dataset containing missing or coarsened values, to predict one or more
variables from their predictive distribution given the
observed data and parameters from the fitted model.
cvamPredict(form, obj, data, freq, meanSeries = TRUE, sep = ".")
A data frame containing the predicted probabilities or frequencies,
with an attribute colFrame
that identifies its columns
a one-sided formula indicating the variable or
variables to be predicted, with variables separated by `+
'
an object produced by cvam
containing
results from a model fit
data frame for prediction, possibly different from the
data used to fit the model contained in obj
variable containing frequencies for
data
. If omitted, all frequencies are taken to be 1
,
meaning that the prediction frame is assumed to contain microdata.
applies when obj
contains results from a
simulation run.
If TRUE
, then the requested predictions are based on
a running mean of cell probabilities over all iterations
after the burn-in period. If FALSE
, then the requested
predictions are based only on the cell probabilities from the final
iteration, and (assuming the run was sufficiently long, if MCMC)
can be regarded as a single draw from their posterior distribution.
character sting used to separate the levels of multiple variables being predicted
Joe Schafer Joseph.L.Schafer@census.gov
Predictions from this function are unlike predictions from a regression model. In regression, prediction is to compute the estimated mean response ar specific values of the predictors. With this function, predictions are based on the predictive distribution for one or more variables given all the observed data, including the variable(s) to be predicted if they are seen. The prediction for a variable that is seen will assign a probability of one to the seen value and zero probability to other values.
For more information, refer to the package vignette Log-Linear Modeling with Missing and Coarsened Values Using the cvam Package.
cvam
,
cvamEstimate
,
cvamImpute
,
cvamLik
fit <- cvam( ~ V1 + V2, freq=n, data=crime )
cvamPredict( ~ V1, fit, data=crime, freq=n ) # predict frequencies
cvamPredict( ~ V1, fit, data=crime ) # predict probabilities
Run the code above in your browser using DataLab