Page 1 of 1

Error running jmv::anovaRM with a between-subj interaction

Posted: Sun Nov 13, 2022 8:00 pm
by bsagarin
I am trying to run a three-way mixed-model ANOVA with one within-subject variable and two between-subjects variables. The analysis runs correctly in JAMOVI using ANOVA-->Repeated Measures ANOVA, but when I try the syntax in R, I get an error:

Code: Select all

jmv::anovaRM(data = disgData,
  rm = list(list(label="disgustType", levels=c("moral","sexual","pathogen"))),
  rmCells = list(list(measure="moralDisgust",cell="moral"),
                 list(measure="sexualDisgust",cell="sexual"),
                 list(measure="pathogenDisgust",cell="pathogen")),
  bs = vars(instructions, gender),
  rmTerms = ~ disgustType,
  bsTerms = ~ instructions + gender + instructions:gender)
Error in if (term == "Residual") { : the condition has length > 1

The analysis runs without an error if I leave out the interaction term:

Code: Select all

jmv::anovaRM(data = disgData,
  rm = list(list(label="disgustType", levels=c("moral","sexual","pathogen"))),
  rmCells = list(list(measure="moralDisgust",cell="moral"),
                 list(measure="sexualDisgust",cell="sexual"),
                 list(measure="pathogenDisgust",cell="pathogen")),
  bs = vars(instructions, gender),
  rmTerms = ~ disgustType,
  bsTerms = ~ instructions + gender)
The code with the interaction ran correctly last year (I teach a graduate ANOVA class each fall, and I used the same demonstration last year).

I am using R version 4.2.2, R Studio version 2022.07.2 Build 576, and JAMOVI version 2.3.18.0. I did a fresh install of all three and the jmv package to confirm the error.

I've attached a copy of the dataset (from Lee, Ambler, & Sagarin, 2014, Archives of Sexual Behavior, Volume 43, pages 1115-1121). I loaded the dataset using:

Code: Select all

disgData <- read.csv("Disgust data.csv")
Thank you for your help!

- Brad

Re: Error running jmv::anovaRM with a between-subj interacti

Posted: Tue Nov 15, 2022 10:33 am
by Ravi
Hi Brad,

Thank you for the bug report! I found out where the issue is and fixed it in this pull request: https://github.com/jamovi/jmv/pull/364. On my version of R (4.0.2) only a warning is given, so one of the later R versions probably promoted these types of issues to an error instead of a warning. Nonetheless, good to fix this.

You can already try this fix out by installing jmv through github:

Code: Select all

devtools::install_github("https://github.com/raviselker/jmv/tree/bugifx/fix-bug-that-gives-warning")
Please let us know whether this fixes your issue :)

Cheers,
Ravi

Re: Error running jmv::anovaRM with a between-subj interacti

Posted: Tue Nov 15, 2022 10:36 am
by Ravi
FYI, it looks like the promotion from warning to error happened in R 4.2.0. From the release notes:
Calling if() or while() with a condition of length greater than one gives an error rather than a warning...

Re: Error running jmv::anovaRM with a between-subj interacti

Posted: Tue Nov 15, 2022 2:22 pm
by bsagarin
Hi Ravi,

Thank you! The update fixed the issue! I will alert my students and have them install the update.

- Brad