| impute {dembase} | R Documentation |
Imputes missing values by fitting an additive or multiplicative main effects model to the non-missing data, and then randomly drawing values for the missing values, based on predictions from the model.
impute(object, mult = NULL, max = NULL) ## S4 method for signature 'CountsWithSubtotals' impute(object, mult = NULL, max = NULL) ## S4 method for signature 'DemographicArray' impute(object, mult = NULL, max = NULL)
object |
Object of class |
mult |
If |
max |
Numeric vector giving maximum values for |
impute performs a single imputation based on a simple, and not
necessarily appropriate, model. impute is useful for generating
starting values for iterative calculations, for tidying data with a small
proportion of missing values, or for rough approximations. For more
sophisticated approaches to the imputation of demographic data see package
demest.
If mult is TRUE, meaning that the multiplicative model is
used, all non-missing values must be non-negative (0s are omitted from the
model.) If the mult is TRUE all imputed values are guaranteed
to be non-negative.
If all non-missing values are non-negative integers, imputed values are drawn from a Poisson distribution. Other they are drawn from a normal distribution.
The max argument is useful when object represents draws from a
binomial distribution. Setting max to the number of trials for each
cell ensures that the imputed number of successes does not exceed the number
of trials.
An object with the same class as object, with the missing
values filled in.
Little, RJA and Rubin, DB. 2002. Statistical Analysis with Missing Data, Wiley.
DemographicArray, perturb,
extrapolate
library(demdata) popn <- Counts(VAPopn) popn[sample(length(popn), size = 5)] <- NA popn impute(popn) impute(popn, mult = TRUE) impute(popn, max = 500)