[R-sig-ME] Predicted probabilites with CIs for multilevel logistic regression with prior weights
@@m_cr@w|ey @end|ng |rom w@rpm@||@net
Tue Jun 18 03:44:25 CEST 2019
Hi again Daniel (and list),
Thanks again for the below. I have been using the ggpredict() function, and it works well. However, should I be using the type = "re" parameter? Or is this only required when attempting to predict values for each group? (I have read the ggeffects documentation on this, but it's still not entirely clear to me).
When adding type="re", the confidence intervals become very wide, which is obviously not ideal.
On Tue, 11 Jun 2019, at 03:30, d.luedecke using uke.de wrote:
> Hi Sam,
> you could the "ggeffects" package
> (https://strengejacke.github.io/ggeffects/), and there is also an example
> for a logistic mixed effects model
> del.html), which might help you.
> For binomial models, using weights often results in the following warning:
> #> non-integer #successes in a binomial glm!
> However, CIs for the predicted probabilities can be calculated nevertheless
> (at least in my quick example). Note that afaik, mixed models in R do
> correctly not account for sampling weights. However, Thomas Lumley, author
> of the survey-package, works on a survey-function for mixed models
> (https://github.com/tslumley/svylme), probably the GitHub version is quite
> stable (haven't tested yet).
> An alternative would be the "scale_weights()" function from the
> #rescale-model-weights-for-complex-samples ), which rescales sampling
> weights so they can be used as "weights" for the mixed models function you
> have in R (lme4, lme, ...).
> Based on that function, I have a small example that demonstrates how to
> compute predicted probabilities for mixed models with (sampling) weights
> (ignore the warnings, this is just for demonstration purposes):
> library(sjstats) # for scale_weights() and sample data
> library(ggeffects) # for ggpredict()
> nhanes_sample$bin <- rbinom(nrow(nhanes_sample), 1, prob = .3)
> nhanes_sample <- scale_weights(nhanes_sample, SDMVSTRA, WTINT2YR)
> m <- glmer(
> bin ~ factor(RIAGENDR) * age + factor(RIDRETH1) + (1 | SDMVPSU),
> family = binomial(),
> data = nhanes_sample,
> weights = svywght_a
> ggpredict(m, c("age", "RIAGENDR")) %>% plot()
> -----Ursprüngliche Nachricht-----
> Von: R-sig-mixed-models <r-sig-mixed-models-bounces using r-project.org> Im
> Auftrag von Sam Crawley
> Gesendet: Montag, 10. Juni 2019 10:36
> An: r-sig-mixed-models using r-project.org
> Betreff: [R-sig-ME] Predicted probabilites with CIs for multilevel logistic
> regression with prior weights
> Hello all,
> I am doing a multilevel binomial logistic regression using lme4, and the
> survey data I am using requires weights to be used. I would like to
> calculate various predicted probabilities with confidence intervals based on
> the estimated model. The predict function obviously doesn't give me standard
> errors, and the recommended method to get these is to use the bootMer
> However, in my case, the weights provided are not integers, and the bootMer
> function exits with an error if the weights are not integers (I raised a
> GitHub issue about this, and was pointed to this list:
> https://github.com/lme4/lme4/issues/524 ).
> So my question is, what is the best way to calculate the predicted
> probabilities (with confidence intervals) in my case?
> I would appreciate any help you can give me, and I'm happy to provide more
> details if required.
> Sam Crawley.
> R-sig-mixed-models using r-project.org mailing list
> Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen
> Rechts; Gerichtsstand: Hamburg | www.uke.de
> Vorstandsmitglieder: Prof. Dr. Burkhard Göke (Vorsitzender), Prof. Dr.
> Dr. Uwe Koch-Gromus, Joachim Prölß, Marya Verdel
> SAVE PAPER - THINK BEFORE PRINTING
More information about the R-sig-mixed-models