anovaRM() adding covariates

General help and assistance with jamovi. Bug reports can be made at our issues page: https://github.com/jamovi/jamovi/issues . (If you're unsure feel free to discuss it here)
Post Reply
zoemao
Posts: 3
Joined: Fri Aug 11, 2023 8:17 pm

anovaRM() adding covariates

Post by zoemao »

I am conducting a two-way repeated measures ANOVA with one covariate. My variables are:
- DV: percentage (continuous)
- 2 categorical IV: diagnosis (2 levels: yes, no) & activity (4 levels: indep.craft, inperson, online, video). activity is my focal variable here.
- Covariate: age (continuous)

Here is my syntax:

Code: Select all

anovaRM(data,
        rm = list(
          list(
            label = "activity",
            levels = c("indep.craft", "inperson", "online", "video"))),
        rmCells = list(
          list(
            measure = "indep.craft",
            cell = "indep.craft"),
          list(
            measure = "inperson",
            cell = "inperson"),
          list(
            measure = "online",
            cell = "online"),
          list(
              measure = "video",
              cell = "video")),
        rmTerms = list(
          "activity"),
        bs = "diagnosis",
        bsTerms = list(
          "diagnosis"),
        cov = "age",
        effectSize = "partEta",
        ss = '3', #type III (partial) sum of squares - appropriate for use when analyzing unbalanced data, including data with missing values
        spherTests = TRUE,
        leveneTest = TRUE,
        postHoc = "activity",
        postHocCorr = 'bonf')
It runs. But the results are the same whether or not I have

Code: Select all

cov = "age"
in the syntax, which makes me think I've done something wrong. Does anyone have any insights? Really appreciate it!
User avatar
jonathon
Posts: 2627
Joined: Fri Jan 27, 2017 10:04 am

Re: anovaRM() adding covariates

Post by jonathon »

a quick sanity check here might be to run the same analysis in jamovi, and see if you get the same results.

jonathon
zoemao
Posts: 3
Joined: Fri Aug 11, 2023 8:17 pm

Re: anovaRM() adding covariates

Post by zoemao »

Thank you jonathon! I did the same analyses in jamovi online, and it seems that even when I specified the covariate in R, the results I got were still for without the covariate.

Is there anything I should revise when writing the code to include the covariate?
Saumya
Posts: 2
Joined: Wed Aug 16, 2023 2:16 am

Re: anovaRM() adding covariates

Post by Saumya »

Hello Zoemao and Jonathon,

I am facing the same problem, whether or not I add a covariate in my anovaRM code makes no difference to the obtained results:

Code: Select all

RMA1 <- anovaRM(data,
        rm = list(
          list(label = "X",
               levels = c("X1", "X2", "X3"))),
        rmCells = list(
          list(
            measure = 'X1_Col',
            cell = 'X1'),
          list(
            measure = 'X2_Col',
            cell = 'X2'),
          list(
            measure = 'X3_Col',
            cell = 'X3')),
        rmTerms = list(
          'X'),
        cov = "TiA_PtT")

If I remove [cov = "TiA_PtT"] from this code, I get the exact same results. Seems like anovarRM is not including the covariate in the analysis, is there a way to ensure that it does include it?

Thanks!
User avatar
jonathon
Posts: 2627
Joined: Fri Jan 27, 2017 10:04 am

Re: anovaRM() adding covariates

Post by jonathon »

> I did the same analyses in jamovi online, and it seems that even when I specified the covariate in R, the results I got were still for without the covariate.

sorry, i'm a bit thrown by the "even when I specified the covariate in R" ... if you specify the covariate in jamovi, does it give you the results you expect?

jonathon
zoemao
Posts: 3
Joined: Fri Aug 11, 2023 8:17 pm

Re: anovaRM() adding covariates

Post by zoemao »

Sorry for the late reply! When I specify the covariate ("age" in my case) in jamovi, it seems to work (i.e., it gives a different result as compared to when I do not add a covariate).

However, in R, when I both write and do not write the line [cov = "age"], I get the same result.

Thank you!
Saumya
Posts: 2
Joined: Wed Aug 16, 2023 2:16 am

Re: anovaRM() adding covariates

Post by Saumya »

Hello everyone,

I was wondering if there is any update on the covariate question? I need to do a mixed model repeated measure ANCOVA in R and anovaRM() seems like the most suitable option so far.

Cheers
User avatar
jonathon
Posts: 2627
Joined: Fri Jan 27, 2017 10:04 am

Re: anovaRM() adding covariates

Post by jonathon »

ah! sorry for the delay. there is a problem here. a workaround for the time being is to provide the names of the between subjscts terms to the bsTerms argument as well. for example, in the following i specify 'Gender2' to `cov` as well as `bsTerms`.

Code: Select all

data('bugs', package = 'jmv')

Gender2 <- ifelse(bugs$Gender == 'Male', 1, 0)
bugs <- cbind(bugs, Gender2)

jmv::anovaRM(
  data = bugs,
  rm = list(
    list(
      label = 'Frightening',
      levels = c('Low', 'High'))),
  rmCells = list(
    list(
      measure = 'LDLF',
      cell = 'Low'),
    list(
      measure = 'LDHF',
      cell = 'High')),
  cov='Gender2',
  rmTerms = list(
    'Frightening'),
  bsTerms='Gender2'
  )
Post Reply