Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

multilevel correlation for varying slopes #203

Open
btcrewther opened this issue Jul 20, 2022 · 10 comments
Open

multilevel correlation for varying slopes #203

btcrewther opened this issue Jul 20, 2022 · 10 comments

Comments

@btcrewther
Copy link

It would be useful to compute the multilevel correlation as a random intercept & random slope mixed-effects model, which allows ID slopes to vary. This option, along with the current approach (random-intercept only model), ensures greater user flexibility.

@IndrajeetPatil IndrajeetPatil transferred this issue from easystats/datawizard Jul 20, 2022
@bwiernik
Copy link
Contributor

The partial and mulitlevel arguments are intended to facilitate basic adjustment for variables (partial correlations). For more complex or bespoke modeling, I recommend fitting a mixed effects model directly using a full-featured package such as lme4, glmmTMB, or brms.

@bwiernik bwiernik closed this as not planned Won't fix, can't repro, duplicate, stale Jul 20, 2022
@DominiqueMakowski
Copy link
Member

DominiqueMakowski commented Jul 21, 2022

For more complex or bespoke modeling, I recommend fitting a mixed effects model directly

Agree with that

That said, we could also use that opportunity to add more flexibility to the underlying function datawizard::adjust

datawizard/R/adjust.R

Lines 108 to 110 in e35420b

formula_random <- stats::as.formula(paste("~", paste(paste0("(1|", facs, ")"), collapse = " + ")))
} else {
formula_random <- paste("+", paste(paste0("(1|", facs, ")"), collapse = " + "))

Currently the multilevel argument is FALSE / TRUE and if TRUE sets up random intercepts.

We could allow for multilevel="intercept" (same as TRUE) + multilevel="full" (slopes + intercept), in which case it will add the effect as a random slope

@DominiqueMakowski DominiqueMakowski transferred this issue from easystats/correlation Jul 21, 2022
@bwiernik
Copy link
Contributor

The multilevel argument itself is misleadingly named IMO. I would expect it to decompose correlations into within and between components. Instead, it adjusts for person factors, either with or without partial pooling. I don't really understand the use for the results it currently reports.

@DominiqueMakowski
Copy link
Member

It's mostly used in the case of multilevel correlations afaik, with the common usecase being to somewhat take into account some grouping factors. Obviously not ideal, but can be useful in exploratory analyses (and I've heard via various sources that it could be quite a popular feature of correlation).

In that context, having a "full" random effect specification y ~ x + (x | g) is not unreasonable i think

@bwiernik
Copy link
Contributor

It's mostly used in the case of multilevel correlations

I don't know what you mean. When I hear "multilevel correlation", I think the within/between correlations computed by eg https://www.rdocumentation.org/packages/psych/versions/2.2.5/topics/statsBy

What we currently compute is neither within nor between

@DominiqueMakowski
Copy link
Member

right, I meant correlation partialized via mixed/multilevel models (https://github.com/easystats/correlation#multilevel-correlations)

@bwiernik
Copy link
Contributor

bwiernik commented Jul 21, 2022

What I'm trying to say is that I don't understand what quantity such a estimator is estimating. What is the context in which this quantity is used?

@DominiqueMakowski
Copy link
Member

it then converts the coefficients to "partialized" correlations, and is used as such

@IndrajeetPatil
Copy link
Member

Why is this back in datawizard, @DominiqueMakowski? I thought this was about correlation analysis?

@DominiqueMakowski
Copy link
Member

Adjust was always in datawizard

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

No branches or pull requests

4 participants