Skip to content
Prev 2416 / 5636 Next

[R-meta] "Categorical" moderator varying within and between studies

Thank you, James. For uniformity, I always (i.e., for both categorical &
numeric predictors) use the following method (using a dataset I found on
Stack Overflow).

So, in the case below, you're saying  gender_M_btw is the contextual effect
itself?

Simon

library(dplyr)
library(fastDummies)
library(lme4)

hsb <- read.csv("
https://raw.githubusercontent.com/rnorouzian/e/master/hsb.csv")

hsb2 <- hsb %>%
mutate(gender = ifelse(female==0,"M","F")) %>%   # create 'gender? from
variable ?female?
dummy_columns(select_columns = "gender") %>%     # create dummies for
'gender? (creates 2 but we need 1)
group_by(sch.id) %>%                             # group by cluster id '
sch.id'
mutate(across(starts_with("gender_"), list(wthn = ~ . - mean(.), btw = ~
mean(.))))

mg_b_w <- lmer(math ~ gender_M_wthn + gender_M_btw + (1|sch.id), data =
hsb2)
On Thu, Oct 29, 2020 at 1:31 PM James Pustejovsky <jepusto at gmail.com> wrote:

            

  
  
Message-ID: <CACgv6yVAw1kTOiR=WA1vmtHBZpjhV7y57Bh8+b5E9+iUAwi7ng-2218@mail.gmail.com>
In-Reply-To: <CAFUVuJwZSijD7VPaQJgwrSn8zPDJ9vcWteka5FZ6vfvijXAH4w@mail.gmail.com>