Combines estimates from a tidy table
Arguments
- w
A
data.framewith parameter estimates in tidy format (see details).- type
A string, either
"minimal","tests"or"all". Use minimal to mimic the output ofsummary(pool(fit)). The default is"all".- conf.int
Logical indicating whether to include a confidence interval.
- conf.level
Confidence level of the interval, used only if
conf.int = TRUE. Number between 0 and 1.- exponentiate
Flag indicating whether to exponentiate the coefficient estimates and confidence intervals (typical for logistic regression).
- dfcom
A positive number representing the degrees of freedom of the residuals in the complete-data analysis. The
dfcomargument is used for the Barnard-Rubin adjustment. In a linear regression,dfcomwould be equivalent to the number of independent observation minus the number of fitted parameters, but the expression becomes more complex for regularized, proportional hazards, or other semi-parametric techniques. Only used ifwlacks a column named"df.residual".- custom.t
A custom character string to be parsed as a calculation rule for the total variance
t. The custom rule can use the other calculated pooling statistics. The defaulttcalculation has the form".data$ubar + (1 + 1 / .data$m) * .data$b".- rule
A string indicating the pooling rule. Currently supported are
"rubin1987"(default, for analyses applied to multiply-imputed incomplete data) and"reiter2003"(for analyses applied to synthetic data created from complete data).- ...
Arguments passed down
Value
pool.table() returns a data.frame with aggregated
estimates, standard errors, confidence intervals and statistical tests.
The meaning of the columns is as follows:
term | Parameter name |
m | Number of multiple imputations |
estimate | Pooled complete data estimate |
std.error | Standard error of estimate |
statistic | t-statistic = estimate / std.error |
df | Degrees of freedom for statistic |
p.value | One-sided P-value under null hypothesis |
conf.low | Lower bound of c.i. (default 95 pct) |
conf.high | Upper bound of c.i. (default 95 pct) |
riv | Relative increase in variance |
fmi | Fraction of missing information |
ubar | Within-imputation variance of estimate |
b | Between-imputation variance of estimate |
t | Total variance, of estimate |
dfcom | Residual degrees of freedom in complete data |
Details
The input data w is a data.frame with columns named:
term | a character or factor with the parameter names |
estimate | a numeric vector with parameter estimates |
std.error | a numeric vector with standard errors of estimate |
residual.df | a numeric vector with the degrees of freedom |
Columns 1-3 are obligatory. Column 4 is optional. Usually,
all entries in column 4 are the same. The user can omit column 4,
and specify argument pool.table(..., dfcom = ...) instead.
If both are given, then column residual.df takes precedence.
If neither are specified, then mice tries to calculate the
residual degrees of freedom. If that fails (e.g. because there is
no information on sample size), mice sets dfcom = Inf.
The value dfcom = Inf is acceptable for large samples
(n > 1000) and relatively concise parametric models.
Examples
# conventional mice workflow
imp <- mice(nhanes2, m = 2, maxit = 2, seed = 1, print = FALSE)
fit <- with(imp, lm(chl ~ age + bmi + hyp))
pld1 <- pool(fit)
pld1$pooled
#> term m estimate ubar b t dfcom df
#> 1 (Intercept) 2 -27.061909 2054.489358 826.519323 3294.268342 20 4.3583827
#> 2 age40-59 2 63.827655 285.274591 643.397385 1250.370669 20 1.1964970
#> 3 age60-99 2 99.694020 346.106025 547.775204 1167.768830 20 1.4709221
#> 4 bmi 2 6.839737 2.568036 1.595641 4.961497 20 2.9540555
#> 5 hypyes 2 -11.495286 296.595683 1800.375408 2997.158795 20 0.7324639
#> riv lambda fmi
#> 1 0.6034487 0.3763443 0.5458532
#> 2 3.3830425 0.7718480 0.8805825
#> 3 2.3740205 0.7036177 0.8361999
#> 4 0.9320202 0.4824071 0.6562694
#> 5 9.1052003 0.9010411 0.9540671
# using pool.table() on tidy table
tbl <- summary(fit)[, c("term", "estimate", "std.error", "df.residual")]
tbl
#> # A tibble: 10 × 4
#> term estimate std.error df.residual
#> <chr> <dbl> <dbl> <dbl>
#> 1 (Intercept) -6.73 45.0 20
#> 2 age40-59 45.9 18.5 20
#> 3 age60-99 83.1 17.8 20
#> 4 bmi 5.95 1.53 20
#> 5 hypyes 18.5 16.9 20
#> 6 (Intercept) -47.4 45.7 20
#> 7 age40-59 81.8 15.1 20
#> 8 age60-99 116. 19.4 20
#> 9 bmi 7.73 1.68 20
#> 10 hypyes -41.5 17.6 20
pld2 <- pool.table(tbl, type = "minimal")
pld2
#> term m estimate ubar b t dfcom df
#> 1 (Intercept) 2 -27.061909 2054.489358 826.519323 3294.268342 20 4.3583827
#> 2 age40-59 2 63.827655 285.274591 643.397385 1250.370669 20 1.1964970
#> 3 age60-99 2 99.694020 346.106025 547.775204 1167.768830 20 1.4709221
#> 4 bmi 2 6.839737 2.568036 1.595641 4.961497 20 2.9540555
#> 5 hypyes 2 -11.495286 296.595683 1800.375408 2997.158795 20 0.7324639
#> riv lambda fmi
#> 1 0.6034487 0.3763443 0.5458532
#> 2 3.3830425 0.7718480 0.8805825
#> 3 2.3740205 0.7036177 0.8361999
#> 4 0.9320202 0.4824071 0.6562694
#> 5 9.1052003 0.9010411 0.9540671
identical(pld1$pooled, pld2)
#> [1] TRUE
# conventional workflow: all numerical output
all1 <- summary(pld1, type = "all", conf.int = TRUE)
all1
#> term m estimate std.error statistic df p.value
#> 1 (Intercept) 2 -27.061909 57.395717 -0.4714970 4.3583827 0.65992966
#> 2 age40-59 2 63.827655 35.360581 1.8050511 1.1964970 0.28967781
#> 3 age60-99 2 99.694020 34.172633 2.9173643 1.4709221 0.14163099
#> 4 bmi 2 6.839737 2.227442 3.0706691 2.9540555 0.05565033
#> 5 hypyes 2 -11.495286 54.746313 -0.2099737 0.7324639 0.87703238
#> conf.low conf.high riv lambda fmi ubar
#> 1 -181.3808450 127.25703 0.6034487 0.3763443 0.5458532 2054.489358
#> 2 -243.6825561 371.33787 3.3830425 0.7718480 0.8805825 285.274591
#> 3 -111.7011748 311.08921 2.3740205 0.7036177 0.8361999 346.106025
#> 4 -0.3117585 13.99123 0.9320202 0.4824071 0.6562694 2.568036
#> 5 -1717.5339526 1694.54338 9.1052003 0.9010411 0.9540671 296.595683
#> b t dfcom
#> 1 826.519323 3294.268342 20
#> 2 643.397385 1250.370669 20
#> 3 547.775204 1167.768830 20
#> 4 1.595641 4.961497 20
#> 5 1800.375408 2997.158795 20
# pool.table workflow: all numerical output
all2 <- pool.table(tbl)
all2
#> term m estimate std.error statistic df p.value
#> 1 (Intercept) 2 -27.061909 57.395717 -0.4714970 4.3583827 0.65992966
#> 2 age40-59 2 63.827655 35.360581 1.8050511 1.1964970 0.28967781
#> 3 age60-99 2 99.694020 34.172633 2.9173643 1.4709221 0.14163099
#> 4 bmi 2 6.839737 2.227442 3.0706691 2.9540555 0.05565033
#> 5 hypyes 2 -11.495286 54.746313 -0.2099737 0.7324639 0.87703238
#> conf.low conf.high riv lambda fmi ubar
#> 1 -181.3808450 127.25703 0.6034487 0.3763443 0.5458532 2054.489358
#> 2 -243.6825561 371.33787 3.3830425 0.7718480 0.8805825 285.274591
#> 3 -111.7011748 311.08921 2.3740205 0.7036177 0.8361999 346.106025
#> 4 -0.3117585 13.99123 0.9320202 0.4824071 0.6562694 2.568036
#> 5 -1717.5339526 1694.54338 9.1052003 0.9010411 0.9540671 296.595683
#> b t dfcom
#> 1 826.519323 3294.268342 20
#> 2 643.397385 1250.370669 20
#> 3 547.775204 1167.768830 20
#> 4 1.595641 4.961497 20
#> 5 1800.375408 2997.158795 20
class(all1) <- "data.frame"
identical(all1, all2)
#> [1] TRUE
