Hello, everyone, I’m a new user of Julia, previously using R/Python. I’m trying to run an ANOVA with Julia but got different result from R.
The test data is extracted from Jamovi: test_data.csv - Pastebin.com
The R code is:
data <- read.csv('./data/test_data.csv')
data$cond <- as.factor(data$cond)
data$subj <- as.factor(data$subj)
anova(
lm(formula = y ~ subj + cond + subj*cond, data = data)
)
The result is:
Analysis of Variance Table
Response: y
Df Sum Sq Mean Sq F value Pr(>F)
subj 49 13872 283.10 22.1259 < 2.2e-16 ***
cond 1 706 705.54 55.1421 1.466e-13 ***
subj:cond 49 3827 78.11 6.1046 < 2.2e-16 ***
Residuals 2900 37105 12.79
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Both Jamovi and Pure R returns the same result.
But while I’m trying to run an ANOVA in Julia with the following code:
using StatsModels, DataFrames, CSV, GLM, ANOVA;
data = CSV.read("./data/test_data.csv");
categorical!(data, :cond);
categorical!(data, :subj);
anova(lm(@formula(y~cond+subj+cond*subj),data))
It returns a quite different result:
4×6 DataFrame
│ Row │ Source │ DF │ SS │ MSS │ F │ p │
│ │ String │ Abstract… │ Abstract… │ Abstract… │ Abstract… │ Abstract… │
├─────┼─────────────┼───────────┼───────────┼───────────┼───────────┼─────────────┤
│ 1 │ cond │ 1.0 │ 0.661981 │ 0.661981 │ 0.0517376 │ 0.820083 │
│ 2 │ subj │ 49.0 │ 7980.08 │ 162.859 │ 12.7283 │ 9.31968e-90 │
│ 3 │ cond & subj │ 49.0 │ 3827.32 │ 78.1085 │ 6.10462 │ 2.22324e-35 │
│ 4 │ Residuals │ 2900.0 │ 37105.4 │ 12.795 │ 0.0 │ 0.0 │
It’s quite confusing, I have no idea what happened to my code. I would be grateful if I could get your generous help .