[R-meta] "Categorical" moderator varying within and between studies
Gerta Ruecker
ruecker @end|ng |rom |mb|@un|-|re|burg@de
Wed Jun 3 15:45:25 CEST 2020
Simon
Maybe there should not be a line break between "Relative and Rating"?
For characters, for example if they are used as legends, line breaks
sometimes matter.
Best,
Gerta
Am 03.06.2020 um 15:32 schrieb James Pustejovsky:
> I'm not sure what produced that error and I cannot reproduce it. It may
> have to do something with the version of dplyr. Here's an alternative way
> to recode the Scoring variable, which might be less prone to versioning
> differences:
>
> library(dplyr)
> library(fastDummies)
> library(robumeta)
>
> data("oswald2013")
>
> oswald_centered <-
> oswald2013 %>%
>
> # make dummy variables
> mutate(
> Scoring = factor(Scoring,
> levels = c("Absolute", "Difference Score", "Relative
> Rating"),
> labels = c("Absolute", "Difference", "Relative"))
> ) %>%
> dummy_columns(select_columns = "Scoring") %>%
>
> # centering by study
> group_by(Study) %>%
> mutate_at(vars(starts_with("Scoring_")),
> list(wthn = ~ . - mean(.), btw = ~ mean(.))) %>%
>
> # calculate Fisher Z and variance
> mutate(
> Z = atanh(R),
> V = 1 / (N - 3)
> )
>
>
> # Use the predictors in a meta-regression model
> # with Scoring = Absolute as the omitted category
>
> robu(Z ~ Scoring_Difference_wthn + Scoring_Relative_wthn +
> Scoring_Difference_btw + Scoring_Relative_btw,
> data = oswald_centered, studynum = Study, var.eff.size = V)
>
> On Tue, Jun 2, 2020 at 10:20 PM Simon Harmel <sim.harmel using gmail.com> wrote:
>
>> Many thanks, James! I keep getting the following error when I run your
>> code:
>>
>> Error: unexpected symbol in:
>> "Rating" = "Relative")
>> oswald_centered"
>>
>> On Tue, Jun 2, 2020 at 10:00 PM James Pustejovsky <jepusto using gmail.com>
>> wrote:
>>
>>> Hi Simon,
>>>
>>> The same strategy can be followed by using dummy variables for each
>>> unique level of a categorical moderator. The idea would be to 1) create
>>> dummy variables for each category, 2) calculate the study-level means of
>>> the dummy variables (between-cluster predictors), and 3) calculate the
>>> group-mean centered dummy variables (within-cluster predictors). Just like
>>> if you're working with regular categorical predictors, you'll have to pick
>>> one reference level to omit when using these sets of predictors.
>>>
>>> Here is an example of how to carry out such calculations in R, using the
>>> fastDummies package along with a bit of dplyr:
>>>
>>> library(dplyr)
>>> library(fastDummies)
>>> library(robumeta)
>>>
>>> data("oswald2013")
>>>
>>> oswald_centered <-
>>> oswald2013 %>%
>>>
>>> # make dummy variables
>>> mutate(
>>> Scoring = recode(Scoring, "Difference Score" = "Difference",
>>> "Relative Rating" = "Relative")
>>> ) %>%
>>> dummy_columns(select_columns = "Scoring") %>%
>>>
>>> # centering by study
>>> group_by(Study) %>%
>>> mutate_at(vars(starts_with("Scoring_")),
>>> list(wthn = ~ . - mean(.), btw = ~ mean(.))) %>%
>>>
>>> # calculate Fisher Z and variance
>>> mutate(
>>> Z = atanh(R),
>>> V = 1 / (N - 3)
>>> )
>>>
>>>
>>> # Use the predictors in a meta-regression model
>>> # with Scoring = Absolute as the omitted category
>>>
>>> robu(Z ~ Scoring_Difference_wthn + Scoring_Relative_wthn +
>>> Scoring_Difference_btw + Scoring_Relative_btw, data = oswald_centered,
>>> studynum = Study, var.eff.size = V)
>>>
>>>
>>> Kind Regards,
>>> James
>>>
>>> On Tue, Jun 2, 2020 at 6:49 PM Simon Harmel <sim.harmel using gmail.com> wrote:
>>>
>>>> Hi All,
>>>>
>>>> Page 13 of *THIS ARTICLE
>>>> <
>>>> https://cran.r-project.org/web/packages/robumeta/vignettes/robumetaVignette.pdf
>>>>> *
>>>> (*top of the page*) recommends that if a *continuous moderator *varies
>>>> both within and across studies in a meta-analysis, a strategy is to break
>>>> that moderator down into two moderators by:
>>>>
>>>> *(a)* taking the mean of each study (between-cluster effect),
>>>>
>>>> *(b)* centering the predictor within each study (within-cluster effect).
>>>>
>>>> BUT what if my original moderator that varies both within and across
>>>> studies is a *"categorical" *moderator?
>>>>
>>>> I appreciate an R demonstration of the strategy recommended.
>>>> Thanks,
>>>> Simon
>>>>
>>>> [[alternative HTML version deleted]]
>>>>
>>>> _______________________________________________
>>>> R-sig-meta-analysis mailing list
>>>> R-sig-meta-analysis using r-project.org
>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-meta-analysis
>>>>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-meta-analysis mailing list
> R-sig-meta-analysis using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-meta-analysis
--
Dr. rer. nat. Gerta Rücker, Dipl.-Math.
Institute of Medical Biometry and Statistics,
Faculty of Medicine and Medical Center - University of Freiburg
Stefan-Meier-Str. 26, D-79104 Freiburg, Germany
Phone: +49/761/203-6673
Fax: +49/761/203-6680
Mail: ruecker using imbi.uni-freiburg.de
Homepage: https://www.uniklinik-freiburg.de/imbi.html
More information about the R-sig-meta-analysis
mailing list