Comments (7)
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.
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.
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.
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.
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.
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.
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)
- Problem treating xยดs as pairs HOT 1
- Request: allow weighting and clustering HOT 2
- Request: order by specification HOT 3
- Singleton control set produces duplicates HOT 1
- Calculate models for all combinations of covariates HOT 2
- Error in run_spec with input res HOT 4
- Run a list of predefined specifications HOT 3
- Request: Perform joint test across specification curves HOT 3
- run_specs following setup_specs HOT 4
- specs using weighted survey data HOT 1
- Bug: `plot_specs()` plot is uninterpretable if there are many covariates. HOT 5
- Models are not found when they are elements of a list. HOT 5
- Don't get "no covariates" in fixed effects regression HOT 1
- How does specr handle dummy coded categorical variables HOT 2
- Categorical independet variable HOT 2
- Testing the effect of an interaction term HOT 4
- Interactions question HOT 2
- How to customise the colours in specr plots HOT 1
- np Package errors HOT 2
- Show choices together with options on the left? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from specr.