jasp-stats / jasp-issues

This repository is solely meant for reporting of bugs, feature requests and other issues in JASP.
59 stars 29 forks source link

Some parameters are not estimable, most likely due to empty cells of the design [Bug]: Keep getting this error? #1924

Closed whiningatlife closed 9 months ago

whiningatlife commented 1 year ago

JASP Version

0.16.4

Commit ID

No response

JASP Module

ANOVA

What analysis are you seeing the problem on?

Repeated Measures ANOVA

What OS are you seeing the problem on?

Windows 10

Bug Description

I am trying to run a repeated measures ANOVA on my data file. It is comparing 3x4 reaction times of my participants. I have attached the data file. Every time I try to run, I get the message "Some parameters are not estimable, most likely due to empty cells of the design" This bug is confusing to me, as I have run the exact same analysis multiple times, in the same design even. These are the things I have tried so far:

Is there anything wrong with my file? I have used the same data generation process for my other files and have not faced this issue. For whatever reason, just this particular data (at this point it is not even the same csv file), that gives this report. pilot3_rt.csv buggy.zip Screenshot (102)

Expected Behaviour

pilot3prac_rt.csv This file with the exact same data type runs perfectly fine.

Steps to Reproduce

  1. Open pilot3_rt
  2. Run repeated measures ANOVA

Log (if any)

No response

Final Checklist

JohnnyDoorn commented 1 year ago

Hi @whiningatlife ,

Thanks for reporting this. I just took a look, and it seems to be an error with the afex package. I have never seen this error before, so I'll have to check with my colleagues. @vandenman @Kucharssim have you encountered this error before? eigenBug.csv dat <- read.csv("eigenBug.csv") myF <- formula(dependent ~ (TrialTypes + Conditions + TrialTypes:Conditions) + Error(subj/(TrialTypes) + subj/(Conditions) + subj/(TrialTypes:Conditions))) afex::aov_car(myF, data=dat, type= 3, factorize = FALSE, include_aov = TRUE) #Error in eigen(SSPE, only.values = TRUE)$values >= sqrt(.Machine$double.eps) : invalid comparison with complex values

Is this perhaps just too few cells for too many levels?

Kind regards, Johnny

vandenman commented 1 year ago

I haven't encountered this error before, but it seems to go wrong here:

https://github.com/cran/car/blob/74fdaaec6bfc93db5dda68a2d59c8a2fa7d5ed57/R/linearHypothesis.R#L384-L389

The value of SSPE for this data set is

                        TrialTypes1:Conditions1 TrialTypes2:Conditions1 TrialTypes1:Conditions2 TrialTypes2:Conditions2 TrialTypes1:Conditions3 TrialTypes2:Conditions3
TrialTypes1:Conditions1              648.268107               140.24416               610.76233               -9.101117               441.75661               155.54922
TrialTypes2:Conditions1              140.244155               528.85637               -53.91929              -85.765128                45.33630               -93.92928
TrialTypes1:Conditions2              610.762332               -53.91929              1424.57258              126.883400               324.92040               148.83660
TrialTypes2:Conditions2               -9.101117               -85.76513               126.88340               28.134290               -12.45985                13.20477
TrialTypes1:Conditions3              441.756609                45.33630               324.92040              -12.459848               321.61830               125.24908
TrialTypes2:Conditions3              155.549216               -93.92928               148.83660               13.204766               125.24908                72.60872

which looks symmetric, but it is not:

> isSymmetric(SSPE)
[1] FALSE

> SSPE - t(SSPE)
                        TrialTypes1:Conditions1 TrialTypes2:Conditions1 TrialTypes1:Conditions2 TrialTypes2:Conditions2 TrialTypes1:Conditions3 TrialTypes2:Conditions3
TrialTypes1:Conditions1            0.000000e+00            0.000000e+00            0.000000e+00            3.637979e-12            0.000000e+00           -3.637979e-12
TrialTypes2:Conditions1            0.000000e+00            0.000000e+00            3.637979e-12           -3.637979e-12            3.637979e-12           -3.637979e-12
TrialTypes1:Conditions2            0.000000e+00           -3.637979e-12            0.000000e+00            1.091394e-11            0.000000e+00           -7.275958e-12
TrialTypes2:Conditions2           -3.637979e-12            3.637979e-12           -1.091394e-11            0.000000e+00           -1.091394e-11           -1.091394e-11
TrialTypes1:Conditions3            0.000000e+00           -3.637979e-12            0.000000e+00            1.091394e-11            0.000000e+00           -7.275958e-12
TrialTypes2:Conditions3            3.637979e-12            3.637979e-12            7.275958e-12            1.091394e-11            7.275958e-12            0.000000e+00

based on the code/ math, this matrix should be symmetric though. I think that what goes wrong is just floating point rounding errors which cause the matrix to be asymmetric and hence the eigenvalues are complex.

Could be worth opening an issue at the repository of the Car package? I don't think this is something we can fix directly.

MouniaZiat commented 1 year ago

I am having the same issue described by whiningatlife. I was wondering if a solution was provided since this was posted. Many thanks in advance.

tomtomme commented 9 months ago

@MouniaZiat & @whiningatlife I have tested the two jasp files uploaded above with jasp 0.18.3. The refreshed analysis showed no errors. Please reopen, if not fixed on your side.