Pools univariate estimates of m repeated complete data analysis
Usage
pool.scalar(Q, U, n = Inf, k = 1, rule = c("rubin1987", "reiter2003"))
pool.scalar.syn(Q, U, n = Inf, k = 1, rule = "reiter2003")Arguments
- Q
A vector of univariate estimates of
mrepeated complete data analyses.- U
A vector containing the corresponding
mvariances of the univariate estimates.- n
A number providing the sample size. If nothing is specified, an infinite sample
n = Infis assumed.- k
A number indicating the number of parameters to be estimated. By default,
k = 1is assumed.- rule
A string indicating the pooling rule. Currently supported are
"rubin1987"(default, for missing data) and"reiter2003"(for synthetic data created from a complete data set).
Value
Returns a list with components.
m:Number of imputations.
qhat:The
munivariate estimates of repeated complete-data analyses.u:The corresponding
mvariances of the univariate estimates.qbar:The pooled univariate estimate, formula (3.1.2) Rubin (1987).
ubar:The mean of the variances (i.e. the pooled within-imputation variance), formula (3.1.3) Rubin (1987).
b:The between-imputation variance, formula (3.1.4) Rubin (1987).
t:The total variance of the pooled estimated, formula (3.1.5) Rubin (1987).
r:The relative increase in variance due to nonresponse, formula (3.1.7) Rubin (1987).
df:The degrees of freedom for t reference distribution by the method of Barnard-Rubin (1999).
fmi:The fraction missing information due to nonresponse, formula (3.1.10) Rubin (1987). (Not defined for synthetic data.)
Details
The function averages the univariate estimates of the complete data model, computes the total variance over the repeated analyses, and computes the relative increase in variance due to missing data or data synthesisation and the fraction of missing information.
References
Rubin, D.B. (1987). Multiple Imputation for Nonresponse in Surveys. New York: John Wiley and Sons.
Reiter, J.P. (2003). Inference for Partially Synthetic, Public Use Microdata Sets. Survey Methodology, 29, 181-189.
Examples
# missing data imputation with with manual pooling
imp <- mice(nhanes, maxit = 2, m = 2, print = FALSE, seed = 18210)
fit <- with(data = imp, lm(bmi ~ age))
# manual pooling
summary(fit$analyses[[1]])
#>
#> Call:
#> lm(formula = bmi ~ age)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -8.2464 -2.3464 0.7304 2.0304 6.6536
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 30.623 1.761 17.392 9.92e-15 ***
#> age -1.977 0.908 -2.177 0.04 *
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Residual standard error: 3.695 on 23 degrees of freedom
#> Multiple R-squared: 0.1709, Adjusted R-squared: 0.1348
#> F-statistic: 4.739 on 1 and 23 DF, p-value: 0.04
#>
summary(fit$analyses[[2]])
#>
#> Call:
#> lm(formula = bmi ~ age)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -8.052 -2.537 1.148 1.706 6.848
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 31.209 1.652 18.891 1.67e-15 ***
#> age -2.757 0.852 -3.237 0.00365 **
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Residual standard error: 3.467 on 23 degrees of freedom
#> Multiple R-squared: 0.3129, Adjusted R-squared: 0.2831
#> F-statistic: 10.48 on 1 and 23 DF, p-value: 0.003645
#>
pool.scalar(Q = c(-1.5457, -1.428), U = c(0.9723^2, 1.041^2), n = 25, k = 2)
#> $m
#> [1] 2
#>
#> $qhat
#> [1] -1.5457 -1.4280
#>
#> $u
#> [1] 0.9453673 1.0836810
#>
#> $qbar
#> [1] -1.48685
#>
#> $ubar
#> [1] 1.014524
#>
#> $b
#> [1] 0.006926645
#>
#> $t
#> [1] 1.024914
#>
#> $df
#> [1] 20.97025
#>
#> $r
#> [1] 0.01024122
#>
#> $fmi
#> [1] 0.09272831
#>
# check: automatic pooling using broom
pool(fit)
#> Class: mipo m = 2
#> term m estimate ubar b t dfcom df riv
#> 1 (Intercept) 2 30.91618 2.9147323 0.1716923 3.172271 23 17.28486 0.08835752
#> 2 age 2 -2.36715 0.7751948 0.3047278 1.232286 23 4.70669 0.58964749
#> lambda fmi
#> 1 0.08118427 0.1717756
#> 2 0.37092971 0.5341828
# manual pooling for synthetic data created from complete data
imp <- mice(cars,
maxit = 2, m = 2, print = FALSE, seed = 18210,
where = matrix(TRUE, nrow(cars), ncol(cars))
)
fit <- with(data = imp, lm(speed ~ dist))
# manual pooling: extract Q and U
summary(fit$analyses[[1]])
#>
#> Call:
#> lm(formula = speed ~ dist)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -8.9743 -3.5181 0.4556 3.1834 7.8855
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 10.94236 1.16358 9.404 1.82e-12 ***
#> dist 0.09236 0.02272 4.066 0.000177 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Residual standard error: 4.344 on 48 degrees of freedom
#> Multiple R-squared: 0.2562, Adjusted R-squared: 0.2407
#> F-statistic: 16.53 on 1 and 48 DF, p-value: 0.0001769
#>
summary(fit$analyses[[2]])
#>
#> Call:
#> lm(formula = speed ~ dist)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -8.1788 -2.4704 0.0981 2.3806 7.4421
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 11.96899 1.17022 10.228 1.2e-13 ***
#> dist 0.10350 0.02528 4.093 0.000162 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Residual standard error: 3.677 on 48 degrees of freedom
#> Multiple R-squared: 0.2587, Adjusted R-squared: 0.2433
#> F-statistic: 16.75 on 1 and 48 DF, p-value: 0.0001621
#>
pool.scalar.syn(Q = c(0.12182, 0.13209), U = c(0.02121^2, 0.02516^2), n = 50, k = 2)
#> $m
#> [1] 2
#>
#> $qhat
#> [1] 0.12182 0.13209
#>
#> $u
#> [1] 0.0004498641 0.0006330256
#>
#> $qbar
#> [1] 0.126955
#>
#> $ubar
#> [1] 0.0005414448
#>
#> $b
#> [1] 5.273645e-05
#>
#> $t
#> [1] 0.0005678131
#>
#> $df
#> [1] 463.7127
#>
#> $r
#> [1] 0.1460992
#>
#> $fmi
#> [1] NA
#>
# check: automatic pooling using broom
pool.syn(fit)
#> Class: mipo m = 2
#> term m estimate ubar b t dfcom
#> 1 (Intercept) 2 11.45567489 1.3616682784 5.269746e-01 1.6251555632 48
#> 2 dist 2 0.09792857 0.0005776804 6.203061e-05 0.0006086957 48
#> df riv lambda fmi
#> 1 38.04263 0.5805099 NA NA
#> 2 385.16627 0.1610682 NA NA
