-
Notifications
You must be signed in to change notification settings - Fork 5
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
Added support for lmer
and glmer
mixed model estimation
#9
Comments
You can specify glmer or lmer models at least with random intercepts. But you have to add the random effect part to the formula using my_glmer <- function(formula,data){
glmer(paste(formula, " + (1|group1)", data = data, family = binomial)
}
results <- run_specs(df = example_data,
y = c("y1", "y2"),
x = c("x1", "x2"),
model = c("my_glmer"),
controls = c("c1", "c2"),
subsets = list(group2 = unique(example_data$group2))) However, it is true that we haven't included a full-on framework for random effect modelling. So what you're suggestions makes a lot of sense. Will work on this for the next version. |
Hi -- cool! Since posting, I've actually written a limited update which would at least allow researchers to specify slope components as well. It doesn't permute slope and intercept possibilities across a specified set, as I've suggested above, and also doesn't exclude formulas which specify random slope components when no fixed slopes for the variable in question are also specified, but it might help you get started. I'll make a PU on your new branch and you can decide if you want to carry on working in the direction I've started:) |
Haha. Check out the branch "add_random_effects". I just committed some functionality to add random groups. Simply estimating a random intercept model is comparatively easy then. Great, I'll check your updates. The question to me is: How should random slopes be included? Similar to control variables (no random slope, each individually, all together)? Then again, it depends on respective specifications which random slopes can be included and which not. Have to think about this more. |
Lol. I know. I went back and you'd already started! Yeah, it gets quite complicated as many specifications that are technically possible to implement don't really make theoretical sense (particularly including a random slope component when no fixed component for the predictor is also included). Happy to help where I can... |
Had a short look at your update. Looks good, but I would like to be more systematic about it. As you point out, with this approach, we get specifications that don't make sense... If you don't mind, let me dwell a bit on it and I will get back to you in time. Thanks for raising this issue and also thanks for your update. |
Not to worry, I didn't expect you to merge it anyway. It's not general enough. I played with added a filter function to exclude non-sensical permutations, i.e. in line# 62 of
but that does't work, and I'm not even sure that would be the most principled way of setting up the code. Anyway, cheers. Thanks for the cool package. |
We made small updates to specr to allow for more flexibility in conducting analyses with random effects. Given the vast possibility to include random intercepts, slopes, interactions, etc., we did not include extra arguments in |
Currently,
run_specs
does not appear to support specification of models with random effects (i.e.glmer
orlmer
models). I note that since #3,run_specs
supports customisableglm
s, but would love to see a random effects parameter added torun_specs
, so e.g. the following usage would be possible:where
random_groups
specified the level 2 grouping variables, andrandom_variance_components
specified whether to specify randomly varying intercepts only, or slopes also for listed variables.The text was updated successfully, but these errors were encountered: