This function "pools" (i.e. combines) multiple estimate_means
objects, in
a similar fashion as mice::pool()
.
Arguments
- x
A list of
estimate_means
objects, as returned byestimate_means()
, orestimate_predicted
objects, as returned byestimate_relation()
and related functions. Forpool_slopes()
, must be a list ofestimate_slopes
objects, as returned byestimate_slopes()
.- transform
A function applied to predictions and confidence intervals to (back-) transform results, which can be useful in case the regression model has a transformed response variable (e.g.,
lm(log(y) ~ x)
). For Bayesian models, this function is applied to individual draws from the posterior distribution, before computing summaries. Can also beTRUE
, in which caseinsight::get_transformation()
is called to determine the appropriate transformation-function. Note that no standard errors are returned when transformations are applied.- ...
Currently not used.
Details
Averaging of parameters follows Rubin's rules (Rubin, 1987, p. 76).
Pooling is applied to the predicted values and based on the standard errors
as they are calculated in the estimate_means
or estimate_predicted
objects provided in x
. For objects of class estimate_means
, the predicted
values are on the response scale by default, and standard errors are
calculated using the delta method. Then, pooling estimates and calculating
standard errors for the pooled estimates based ob Rubin's rule is carried
out. There is no back-transformation to the link-scale of predicted values
before applying Rubin's rule.
References
Rubin, D.B. (1987). Multiple Imputation for Nonresponse in Surveys. New York: John Wiley and Sons.
Examples
# example for multiple imputed datasets
data("nhanes2", package = "mice")
imp <- mice::mice(nhanes2, printFlag = FALSE)
# estimated marginal means
predictions <- lapply(1:5, function(i) {
m <- lm(bmi ~ age + hyp + chl, data = mice::complete(imp, action = i))
estimate_means(m, "age")
})
pool_predictions(predictions)
#> Estimated Marginal Means
#>
#> age | Mean | SE | 95% CI | t(1)
#> --------------------------------------------
#> 20-39 | 30.54 | 1.67 | [9.38, 51.71] | 18.33
#> 40-59 | 24.83 | 1.55 | [5.16, 44.50] | 16.04
#> 60-99 | 23.15 | 1.71 | [1.48, 44.82] | 13.58
#>
#> Variable predicted: bmi
#> Predictors modulated: age
#> Predictors averaged: hyp, chl (1.9e+02)
#>
# estimated slopes (marginal effects)
slopes <- lapply(1:5, function(i) {
m <- lm(bmi ~ age + hyp + chl, data = mice::complete(imp, action = i))
estimate_slopes(m, "chl")
})
pool_slopes(slopes)
#> Estimated Marginal Effects
#>
#> Slope | SE | 95% CI | t(Inf) | p
#> --------------------------------------------
#> 0.06 | 0.02 | [0.01, 0.10] | 2.59 | 0.010
#>
#> Marginal effects estimated for chl
#> Type of slope was dY/dX