Applies lm()
to multiply imputed data set
Arguments
- formula
a formula object, with the response on the left of a ~ operator, and the terms, separated by + operators, on the right. See the documentation of
lm
andformula
for details.- data
An object of type 'mids', which stands for 'multiply imputed data set', typically created by a call to function
mice()
.- ...
Additional parameters passed to
lm
Value
An objects of class mira
, which stands for 'multiply imputed
repeated analysis'. This object contains data$m
distinct
lm.objects
, plus some descriptive information.
Details
This function is included for backward compatibility with V1.0. The function
is superseded by with.mids
.
References
Van Buuren, S., Groothuis-Oudshoorn, K. (2011). mice
:
Multivariate Imputation by Chained Equations in R
. Journal of
Statistical Software, 45(3), 1-67.
doi:10.18637/jss.v045.i03
Examples
imp <- mice(nhanes)
#>
#> iter imp variable
#> 1 1 bmi hyp chl
#> 1 2 bmi hyp chl
#> 1 3 bmi hyp chl
#> 1 4 bmi hyp chl
#> 1 5 bmi hyp chl
#> 2 1 bmi hyp chl
#> 2 2 bmi hyp chl
#> 2 3 bmi hyp chl
#> 2 4 bmi hyp chl
#> 2 5 bmi hyp chl
#> 3 1 bmi hyp chl
#> 3 2 bmi hyp chl
#> 3 3 bmi hyp chl
#> 3 4 bmi hyp chl
#> 3 5 bmi hyp chl
#> 4 1 bmi hyp chl
#> 4 2 bmi hyp chl
#> 4 3 bmi hyp chl
#> 4 4 bmi hyp chl
#> 4 5 bmi hyp chl
#> 5 1 bmi hyp chl
#> 5 2 bmi hyp chl
#> 5 3 bmi hyp chl
#> 5 4 bmi hyp chl
#> 5 5 bmi hyp chl
fit <- lm.mids(bmi ~ hyp + chl, data = imp)
#> Warning: Use with(imp, lm(yourmodel)).
fit
#> call :
#> lm.mids(formula = bmi ~ hyp + chl, data = imp)
#>
#> call1 :
#> mice(data = nhanes)
#>
#> nmis :
#> age bmi hyp chl
#> 0 9 8 10
#>
#> analyses :
#> [[1]]
#>
#> Call:
#> lm(formula = formula, data = complete(data, i))
#>
#> Coefficients:
#> (Intercept) hyp chl
#> 21.97200 -2.10751 0.03717
#>
#>
#> [[2]]
#>
#> Call:
#> lm(formula = formula, data = complete(data, i))
#>
#> Coefficients:
#> (Intercept) hyp chl
#> 22.39103 -2.07716 0.03741
#>
#>
#> [[3]]
#>
#> Call:
#> lm(formula = formula, data = complete(data, i))
#>
#> Coefficients:
#> (Intercept) hyp chl
#> 22.14878 -0.20111 0.02421
#>
#>
#> [[4]]
#>
#> Call:
#> lm(formula = formula, data = complete(data, i))
#>
#> Coefficients:
#> (Intercept) hyp chl
#> 23.21196 -2.15281 0.02989
#>
#>
#> [[5]]
#>
#> Call:
#> lm(formula = formula, data = complete(data, i))
#>
#> Coefficients:
#> (Intercept) hyp chl
#> 20.86029 -3.49178 0.05265
#>
#>
#>