[R-sig-ME] lme4 - Mixed Model question

Ben Bolker bbo|ker @end|ng |rom gm@||@com
Mon Jul 13 20:46:35 CEST 2020

    I *think* that if you simply set the values of the covariates you 
want to disregard for each group to 0 for that group, you'll get what 
you want.  I don't think there's a way to do that in the formula 
specification; you can obviously write code to do it, but doing it 
elegantly could be tricky.  If I were doing it I might try something 
*approximately* along the lines of

    vars <- list(g1=c("x1","x2"), g2=c("x2","x3"))

    all_vars <- unique(unlist(vars))

    for (i in seq_along(models)) {

       my_data[group==names(models)[i], setdiff(all_vars, vars[[i]])] <- 0


On 7/13/20 12:06 PM, Axel Urbiz wrote:
> Dear List,
> I’d appreciate any guidance on the following.
> I’m using a mixed effects logistic regression model, to allow coefficients to vary by a group variable. However, my case is not typical in the sense that I need to specify a different set of covariates for each level of the group variable. Say I have 3 covariates {x1, x2, x3} and 2 groups {g1, g2}. I want to specify a model for g1 that only depends on x1 and x2, and a model for g2 that only depends on x2 and x3.
> Note that the 2 groups is just for illustration. I actually have many more than that.
> Is this possible with lme4?
> Thanks,
> Axel.
> _______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models

More information about the R-sig-mixed-models mailing list