kassambara / rstatix

Pipe-friendly Framework for Basic Statistical Tests in R
https://rpkgs.datanovia.com/rstatix/
444 stars 51 forks source link

Error in repeated meausres ANOVA #65

Closed shreyaskumbhare closed 3 years ago

shreyaskumbhare commented 4 years ago

Hi @kassambara. I have started using rstatix recently and have found it super useful. I am performing a repeated measures analysis to test the group and time effect on the dataset. I have been using the aov function previously to do this, however I have recently learned that it doesn't allow me to account for greenhouse-geisser correction. I found that Rstatix's anova_test performs this automatically at the back end (if the data violates the sphericity assumption).

I used the following lines to perform the rANOVA:

res.aov <- anova_test(
  data = pstotaldiv.new.sqrt, dv = Observed, wid = SampleID,
  within = c(Group, TimePoint), 
  )
get_anova_table(res.aov)

However, I received the following error: Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 0 (non-NA) cases

I have even checked my data for NAs, and there are none. I will really appreciate it if you can let me know where exactly am I going wrong. Thank you in advance!

kputschko commented 4 years ago

I also get this error, seemingly out of nowhere.

kassambara commented 4 years ago

Seems to be related to issue #55, fixed in the current dev version.

Please make sure you have installed the latest dev version: devtools::install_github("kassambara/rstatix")

kassambara commented 3 years ago

If you still have this issue, feel free to re-open it

Omidmohaddesi commented 3 years ago

I am also experiencing this issue. I tried to install using devtools::install_github("kassambara/rstatix") but it didn't help.

Here is an example I am trying to run:

df_1 <- data.frame( 
    id = c(1,2,3,4,5,6,7,1,2,3,4,5,6,7,1,2,3,4,5,6,7), 
    time=c(1,1,1,1,1,1,1,2,2,2,2,2,2,2,3,3,3,3,3,3,3), 
    gender=c('Male', 'Male', 'Female', 'Male', 'Female', 'Female', 'Female', 
    'Male', 'Male', 'Female', 'Male', 'Female', 'Female', 'Female', 
    'Male', 'Male', 'Female', 'Male', 'Female', 'Female', 'Female'), 
    value=c(2,3,5,2,4,1,0,4,4,5,3,3,2,5,5,5,5,4,4,3,5)
)

res.aov <- anova_test(
    data = df_1, dv = value, wid = id,
    within = c(gender, time)
)

However, I am getting: Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 0 (non-NA) cases

MelissaRS commented 3 years ago

I am having this exact same issue. I am using a dataset containing 4 columns for running a two-way repeated measures ANOVA. Columns are: Participant, Round, Gender and Score. The code I am trying to run is:

res.aov <- anova_test(data = mydata, dv = Score, wid = Participant, within = c(Round, Gender))
get_anova_table(res.aov)

However, I continuously get the error: Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 0 (non-NA) cases

There are no NA's in my dataset and there are no unused columns either.

Schermafbeelding 2021-06-20 om 14 21 48

I am hoping someone can help me out?

ErikRol23 commented 3 years ago

I was wondering if you resolve your issue. I am experiencing the exact same problem.

Thanks in advance for any sort of help.

lolrenceH commented 3 years ago

same here. dput(df) shows no NA

mariafpv commented 3 years ago

I was also wondering if you resolve this issue. I am experiencing the exact same problem

ConnorEsterwood commented 2 years ago

Also running into this issue.

beyzahv commented 2 years ago

I'm having this issue as well. Did someone find a fix?

GCAT01 commented 1 year ago

Going to add my name to the list. Using rstatix version 0.7.2.999, no NAs in data, no unused columns.

tcaceresm commented 1 year ago

Im also having this issue :(

bh7200 commented 1 year ago

I was having this issue a few days ago and realized what the issue is: the "within" parameter needs to have factors that can all be found among the "id" variable. In other words, for me, I was comparing reading levels (dv) among students (id) when they were in 1st, 2nd, and 3rd grade, and wanted to investigate whether being right-handed or left-handed played a role. I was trying this:

df2 |> anova_test(dv = ReadingScore, wid = Student, within = c(Handedness, GradeLevel))

But since the students weren't both right- and left-handed, it was throwing an error. What I needed to do was:

df2 |> anova_test(dv = ReadingScore, wid = Student, within = GradeLevel, between = Handedness)

Meaning I wanted to look at the effect within each student's GradeLevel, while also looking at the effect between their Handedness.