-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
art.con: error when building model with within-subject style Error term #37
Comments
I can also confirm that the issue is not dataset-specific, as I just ran into the same error with a completely different dataset (only similarly is that both use the same amount of participants & conditions, but measured completely different data). I can also confirm that both datasets were either fully or primarily non-normally distributed, and |
@mjskay Hi Matthew. Apologies for pinging. Any chance you can look into this? Also happy to hear if I got something wrong and the above is actually expected behavior. Thanks! |
I experience the same issue on two datasets. The art-function provides reasonable results, and so does the art.con function if I try to calculate the post-hoc tests for the main effects only. As soon as I try to calculate the interaction, I get the exact same error message as described above. |
@mjskay This is really an issue. Is there any fix planned? |
Can you give a test dataset (on synthetic data will do) giving the error with a reprex? Thanks! |
@mjskay Sure thing: library(ARTool)
data(Higgins1990Table5, package = "ARTool")
m <- art(DryMatter ~ Moisture*Fertilizer + Error(Tray/(Moisture*Fertilizer)), data=Higgins1990Table5)
print(art.con(m, ~ Moisture*Fertilizer))
#> Error in eval(predvars, data, env): object 'Moisture' not found Created on 2023-08-28 with reprex v2.0.2 A slightly different error term gives this error: library(ARTool)
data(Higgins1990Table5, package = "ARTool")
m <- art(DryMatter ~ Moisture*Fertilizer + Error(Tray), data=Higgins1990Table5)
print(art.con(m, ~ Moisture*Fertilizer))
#> Error in X[ii, ii, drop = FALSE] %*% y[ii]: non-conformable arguments Created on 2023-08-28 with reprex v2.0.2 |
…contrasts can be computed on random slopes models, closes #37
Ah okay, I see the issue now. Fixing it for the repeated measures ANOVA is a bit of a pain, but fixing it for mixed effects models was straightforward. I put a fix on the dev branch for mixed effects models, for which you should be able to create an equivalent specification. A model like this: m = art(values ~ X*Y + Error(participant / (X*Y)), data = my_data) As random slopes in a mixed effects model would be: m = art(values ~ X*Y + (X*Y | participant), data = my_data) Which should now work with something like: art.con(m, ~ X*Y) To use this, you have to install the dev branch first via: devtools::install_github("mjskay/ARTool@dev") Let me know if that helps. |
Thanks for the effort! |
Ah, personally I would prefer the random slopes model, but you can get the precisely equivalent model in lmer using the same nesting syntax; something like: m = art(values ~ X*Y + (1 | participant / (X*Y)), data = my_data) See the Remark at the end of section 6.2.2 here. You can verify by using aov() and lmer() directly on the data that these models are equivalent. |
(as I am under a paper deadline myself and the random effects syntax should yield the same model, I am unlikely to fix the error term syntax at the moment - it will require more hairy rewriting of internal code) |
When I do
art_model <- art(values ~ X*Y + Error(participant / (X*Y)), data = my_data)
and run
art.con(art_model, "X:Y")
I receive
Error in eval(predvars, data, env) : object 'X' not found
Mind that
my_data
is a data.frame andX
,Y
andparticipant
are factors.values
is a num.Mind that the following commands do work, and produce sensible results:
And likewise, if I create the model instead with a shorter Error term like this:
art_model <- art(values ~ X*Y + Error(participant), data = my_data)
The original problematic line works and produces sensible results:
art.con(art_model, "X:Y")
Additional alternations, in the hope to provide more help – mind the adjusted Error terms and error message:
My environment:
Thanks for the help @mjskay , and thanks for ARTool! :)
The text was updated successfully, but these errors were encountered: