cvamImpute: Impute Data from a Fitted Model

cvamImputeR Documentation

Impute Data from a Fitted Model

Description

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 randomly impute the true data from their predictive distribution given the observed data and parameters from the fitted model.

Usage

cvamImpute(obj, data, freq, meanSeries = FALSE, synthetic=FALSE)

Arguments

obj

an object produced by cvam containing results from a model fit

data

data frame for imputation, possibly different from the data used to fit the model contained in obj

freq

variable containing frequencies for data. If omitted, all frequencies are taken to be 1, meaning that the imputation frame is assumed to contain microdata.

meanSeries

applies when obj contains results from a simulation run. If TRUE, then the imputations are based on a running mean of cell probabilities over all iterations after the burn-in period. If FALSE, then the imputations 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; see NOTE.

synthetic

if TRUE, then observed values for all variables in the data frame (excluding variables that are conditioned on in the model and regarded as fixed) are set to NA and imputed, producing a dataset that is fully synthetic.

Value

a data frame containing imputed data. If freq was given, the data frame has one row for each cell in the complete-data table and a variable freq containing the frequencies. If freq was not given, the data frame has one row for each microdata observation.

Note

When this function is used within a process for multiple imputation, meanSeries should be set to FALSE, otherwise the imputations will not correctly reflect uncertainty about model parameters.

Author(s)

Joe Schafer Joseph.L.Schafer@census.gov

References

For more information, refer to the package vignette Log-Linear Modeling with Missing and Coarsened Values Using the cvam Package.

See Also

cvam, cvamEstimate, cvamPredict, cvamLik

Examples

# impute from a grouped dataset with frequencies
fit <- cvam( ~ V1 * V2, freq=n, data=crime )
cvamImpute( fit, data=crime, freq=n )
# impute microdata
fit <- cvam( ~ Sex * PolViews * AbAny, data=abortion2000 )
impData <- cvamImpute( fit, data=abortion2000 )
head(impData)

cvam documentation built on March 7, 2023, 5:29 p.m.