drizopoulos/GLMMadaptive

emmeans functions in two-part models: only gives output for "main" model

Closed this issue · 2 comments

I'm running a hurdle lognormal model and I'm interested in the main effects of my categorical variables and the pairwise comparisons. Example of my code:

hln <- mixed_model(missteps_perc ~ Genotype*Session, random = ~ 1 | identifier,
                   data = data, family = hurdle.lognormal(),
                   zi_fixed = ~ Genotype*Session, zi_random = ~ 1 | identifier)
emmeans::joint_tests(hln)
emmeans::emmeans(hln, pairwise ~ Genotype | Session)

The latter two only give outputs for the "main" model, though I would also like to have the output for the "zero_part" model. Is there a way to specify this in the emmeans functions? Or is there a way to create a model object for the "zero_part" model only, so I can use that as a model object in the emmeans functions?


For easiness, a code using the dataset in the Zero-Inflated and Two-Part Mixed Effects Models vignette

First, run the first code block under the semi-continuous data part of the vignette, which creates the dataset DF.


#create categorical time variable
DF$time_categorical[DF$time<2.5] <- "early"
DF$time_categorical[DF$time>=2.5] <- "late"
DF$time_categorical <- as.factor(DF$time_categorical)

#model with interaction in fixed effects zero part and adding nesting in zero part as in model above
km3 <- mixed_model(y ~ sex * time_categorical, random = ~ 1 | id, data = DF, 
                   family = hurdle.lognormal(), n_phis = 1,
                   zi_fixed = ~ sex * time_categorical, zi_random = ~ 1 | id)

#emmeans for main effects and post-hoc tests
joint_tests(km3)
emmeans(km3, pairwise ~ sex|time_categorical)

Update: I've also been posting on stackoverflow about this. Russ Lenth there suggested to use the emmeans::qdrg function. See the possible solution here.

Thanks for sharing this. In many of the required methods I have allowed for the option to extract separately the components for either the main model or the logistic regression for the extra zeros. However, I don't how exactly emmeans can use this. I will look it up.