2
$\begingroup$

Suppose $X$ is a continuous predictor that can vary between studies and outcomes in a 3-level linear mixed model like:

y ~ X + (1 | studies/outcomes)

How can I fit a model to distinguish between $X$'s between and within contributions across studies and outcomes?

PS:

In 2-level models (e.g., y ~ X + (1 | studies)), we can do this by creating 2 variables out of $X$ within each level of studies:

data %>% group_by(studies) %>% mutate(X_between = mean(X), X_within = X-X_between)

And use them as fixed effects:

y ~ X_between + X_within + (1 | studies)

$\endgroup$
4
  • $\begingroup$ Interesting (+1). I have thought about this a little but haven't reached any conclusion. With one grouping variable we just fit the group means as a between variable and the deviations from the group means as within. Did you try doing the same with 2 grouping variables ? Were the results sensible ? $\endgroup$ Commented Aug 30, 2021 at 19:30
  • $\begingroup$ @RobertLong, I can think of two options but wonder which one makes more sense. Option 1: Create mean of X across studies (X_ave_study) and mean of X across outcomes ignoring studies (X_ave_outcome). Option 2: Create mean of X across studies and mean of X across outcomes within studies (X_ave_outcome). For both options, then, I will fit: y ~ X + X_ave_study + X_ave_outcome + (1 | studies/outcomes) . . . $\endgroup$
    – Reza
    Commented Sep 9, 2021 at 4:15
  • $\begingroup$ @RobertLong, . . . In R code: #-- Option 1: data %>% group_by(studies) %>% mutate(X_ave_study = mean(X)) %>% group_by(outcomes) %>% mutate(X_ave_outcome = mean(X)) #-- Option 2: data %>% group_by(studies) %>% mutate(X_ave_study = mean(X)) %>% group_by(outcomes, .add = TRUE) %>% mutate(X_ave_outcome = mean(X)) $\endgroup$
    – Reza
    Commented Sep 9, 2021 at 4:16
  • $\begingroup$ @RobertLong, did you possibly have any opinion on the two options presented by Reza above? $\endgroup$
    – rnorouzian
    Commented Sep 29, 2021 at 18:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.