3

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)

rnorouzian
  • 3,986
  • 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 ? – Robert Long Aug 30 '21 at 19:30
  • @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) . . .

    – Reza Sep 09 '21 at 04:15
  • @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))`

    – Reza Sep 09 '21 at 04:16
  • @RobertLong, did you possibly have any opinion on the two options presented by Reza above? – rnorouzian Sep 29 '21 at 18:14

0 Answers0