Skip to content
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

Error in Multilevel Correlation #280

Closed
teindor opened this issue Feb 23, 2023 · 1 comment
Closed

Error in Multilevel Correlation #280

teindor opened this issue Feb 23, 2023 · 1 comment

Comments

@teindor
Copy link

teindor commented Feb 23, 2023

Hello,
I tried using this simple code: wf %>% correlation(select = "inflated", select2 = "gender",multilevel = TRUE)
I get this message: Error: No random effects terms specified in formula

I tried tweaking the code like this: wf %>% group_by(id) %>% correlation(select = "inflated", select2 = "gender",multilevel = TRUE) or this: wf %>% correlation(select = "inflated", select2 = "gender",multilevel = TRUE, formula = infalted ~ gender + (1|id), with the same error. I haven't find any explanation here or in the documentation.

The random factor should be "id"
Enclosed is the data file
Any ideas?
wf.csv

@mattansb
Copy link
Member

You need to include the grouping variable in select:

wf$id <- factor(wf$id)
correlation::correlation(wf, select = c("id", "inflated", "gender"), multilevel = TRUE)
#> Parameter1 | Parameter2 |    r |            CI | t(539) |     p
#> ---------------------------------------------------------------
#> inflated   |     gender | 0.07 | [-0.02, 0.15] |   1.56 | 0.120
#> 
#> Observations: 541

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants