Giter Site home page Giter Site logo

Comments (7)

masurp avatar masurp commented on August 18, 2024

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 paste(). See below for an example.

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.

from specr.

cbjrobertson avatar cbjrobertson commented on August 18, 2024

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:)

from specr.

masurp avatar masurp commented on August 18, 2024

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.

from specr.

cbjrobertson avatar cbjrobertson commented on August 18, 2024

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...

from specr.

masurp avatar masurp commented on August 18, 2024

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.

from specr.

cbjrobertson avatar cbjrobertson commented on August 18, 2024

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 setup_specs.R adding:

- as_tibble
+ as_tibble %>%
    filter(unlist(Map(function(x, y) grepl(x, y), x, random_var_components)))

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.

from specr.

masurp avatar masurp commented on August 18, 2024

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 run_specs() but extended the functionality to include custom model estimation functions. This โ€“ among other things โ€“ allows to specify multilevel models with various random effects. For a vignette, see:
https://masurp.github.io/specr/articles/random_effects.html

from specr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.