-
-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft pool_means()
and pool_comparisons()
#378
Conversation
Now also works for the prediction functions: library(modelbased)
data("nhanes2", package = "mice")
# regular
m <- lm(bmi ~ age + hyp + chl, data = nhanes2)
estimate_expectation(m, by = "age")
#> Model-based Predictions
#>
#> age | Predicted | SE | 95% CI
#> -----------------------------------------
#> 20-39 | 30.26 | 1.47 | [26.87, 33.65]
#> 40-59 | 23.64 | 1.75 | [19.59, 27.69]
#> 60-99 | 19.08 | 2.80 | [12.63, 25.53]
#>
#> Variable predicted: bmi
#> Predictors modulated: age
#> Predictors controlled: hyp (no), chl (1.9e+02)
# imputed and pooled
imp <- mice::mice(nhanes2, printFlag = FALSE)
predictions <- lapply(1:5, function(i) {
m <- lm(bmi ~ age + hyp + chl, data = mice::complete(imp, action = i))
estimate_expectation(m, by = "age")
})
pool_means(predictions)
#> Model-based Predictions
#>
#> age | Predicted | SE | 95% CI
#> -----------------------------------------
#> 20-39 | 29.01 | 1.65 | [25.78, 32.24]
#> 40-59 | 23.34 | 1.54 | [20.31, 26.36]
#> 60-99 | 23.13 | 2.11 | [18.99, 27.26]
#>
#> Variable predicted: bmi
#> Predictors modulated: age
#> Predictors controlled: hyp (no), chl (1.9e+02) @DominiqueMakowski WDYT? I think this is quite useful, since imputing missing data is increasingly common, as well as using marginal means/adjusted predictions, and now being able to combine both is really powerful. |
I'm not sure |
Renamed |
Fixes #151
@DominiqueMakowski WDYT? pool-function when dealing with missing data. Suggestions for other names, or even one function name (where inside the function, based on the class, automatically deals with pooled means or contrasts)
estimate_means
estimate_contrasts
Created on 2025-02-05 with reprex v2.1.1