impute {dembase} | R Documentation

## Quick and dirty imputation of missing values.

### Description

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.

### Usage

    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)

### Arguments

`object` | Object of class `DemographicArray`.
`mult` | If `TRUE`, a multiplicative model is used to impute values; if `FALSE`, an additive model is used. Defaults to `TRUE` if all non-missing values in `object` are non-negative.
`max` | Numeric vector giving maximum values for `object`. Imputed values respect this maximum; existing values are unaffected. `max` is recycled so that it has the same length as `object`.

### Details

`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.

### Value

An object with the same class as `object`, with the missing values filled in.

### References

Little, RJA and Rubin, DB. 2002. Statistical Analysis with Missing Data, Wiley.

### See Also

`DemographicArray`, `perturb`, `extrapolate`

### Examples

    library(demdata)
    popn <- Counts(VAPopn)
    popn[sample(length(popn), size = 5)] <- NA
    popn
    impute(popn)
    impute(popn, mult = TRUE)
    impute(popn, max = 500)

[Package dembase version 0.0.0.119 Index]