A function to generate priors for multiple overimputation of a variable measured with error.

```
moPrep(x, formula, subset, error.proportion,
gold.standard = !missing(subset), error.sd)
```

x

either a matrix, data.frame, or a object of class "molist"
from a previous `moPrep`

call. The first two derive the priors
from the data given, and the third will derive the priors from the
first `moPrep`

call and add them to the already defined
priors.

formula

a formula describing the nature of the measurement error for the variable. See "Details."

subset

an optional vector specifying a subset of observations which possess measurement error.

error.proportion

an optional vector specifying the fraction of the observed variance that is due to measurement error.

gold.standard

a logical value indicating if values with no measurement error should be used to estimate the measurement error variance.

error.sd

an optional vector specifying the standard error of the measurement error.

An instance of the S3 class "molist" with the following objects:

a four-column matrix of the multiple overimputation priors
associated with the data. Each row of the matrix is ```
c(row,
column, prior.mean, prior.sd)
```

.

a two-column matrix of cells to be overimputed. Each
row of the matrix is of the form `c(row, column)`

, which
indicate the row and column of the cell to be overimputed.

the object name of the matrix or data.frame to which priors refer.

This function generates priors for multiple overimputation of data
measured with error. With the `formula`

arugment, you can specify
which variable has the error, what the mean of the latent data is, and
if there are any other proxy measures of the mismeasured variable. The
general syntax for the formula is: `errvar ~ mean | proxy`

,
where `errvar`

is the mismeasured variable, `mean`

is a
formula for the mean of the latent variable (usually just
`errvar`

itself), and `proxy`

is a another mismeasurement of
the same latent variable. The proxies are used to estimate the
variance of the measurement error.

`subset`

and `gold.standard`

refer to the the rows of the
data which are and are not measured with error. Gold-standard rows are
used to estimate the variance of the
measurement. error. `error.proportion`

is used to estimate the
variance of the measurement error by estimating the variance of the
mismeasurement and taking the proportion assumed to be due to
error. `error.sd`

sets the standard error of the measurement
error directly.

Matthew Blackwell, James Honaker, and Gary King, "Multiple Overimputation: A Unified Approach to Measurement Error and Missing Data" http://gking.harvard.edu/publications/multiple-Overimputation-Unified-Approach-Measurement-Error-And-Missing-Data

```
# NOT RUN {
data(africa)
m.out <- moPrep(africa, trade ~ trade, error.proportion = 0.1)
a.out <- amelia(m.out, ts = "year", cs = "country")
plot(a.out)
m.out <- moPrep(africa, trade ~ trade, error.sd = 1)
a.out <- amelia(m.out, ts = "year", cs = "country")
# }
```

Run the code above in your browser using DataLab