(3x4) 2way anova

ivn

New Member
#1
Hi there. I have a problem with conducting the 3x4 anova test. I have two independent variables - data through 3 years divided into 4 seasons (spring, winter...). The dependent variable is the frequency of patients.

No matter in what statistical software I try to do the test, I always get the same - a nice plot with interactions, but no F test and p value. Can someone try to give an advice on what I am doing wrong?

In the attachment you can find the dataset and a plot which shows the problems I am facing.

Thank you in advance!
 

Miner

TS Contributor
#2
If you included an interaction term, you have a fully saturated model with zero degrees of freedom for the error term, which is used to calculate the F-statistic, which is used to determine the p-value. Since you probably cannot replicate this data, your only option is to remove the interaction term from the model. This will free a degree of freedom for the error term.
 

ivn

New Member
#4
although i am new to R, i tried to do this, and i managed to get some results, but i am not sure if this is correct.

Response: kalk$count
Df Sum Sq Mean Sq F value Pr(>F)
kalk$year 1 32.00 32.00 0.3039 0.5965
kalk$season 1 299.27 299.27 2.8424 0.1303
kalk$year:kalk$season 1 152.10 152.10 1.4446 0.2638
Residuals 8 842.30 105.29
 

Dason

Ambassador to the humans
#5
although i am new to R, i tried to do this, and i managed to get some results, but i am not sure if this is correct.

Response: kalk$count
Df Sum Sq Mean Sq F value Pr(>F)
kalk$year 1 32.00 32.00 0.3039 0.5965
kalk$season 1 299.27 299.27 2.8424 0.1303
kalk$year:kalk$season 1 152.10 152.10 1.4446 0.2638
Residuals 8 842.30 105.29
Looks like you were treating year and season as continuous in this output. That is probably not what you want to do. You want year and season to be in R as 'factors'.
 

ivn

New Member
#6
Thank you Dason, you're right.

I did it another time, but i'd like someone to comment on this. I wrote the test using the coding example from the website below:

https://personality-project.org/r/r.anova.html

> aov.ex2 = aov(klak$N.cases.~klak$season*klak$year)
> summary(aov.ex2)
Df Sum Sq Mean Sq F value Pr(>F)
klak$season 3 877.7 292.56 7.179 0.0435 *
klak$year 1 32.0 32.00 0.785 0.4256
klak$season:klak$year 3 253.0 84.33 2.070 0.2470
Residuals 4 163.0 40.75

I am a bit confused with it. Can someone write the correct R code?
Those results seem to be intuitively correct, because if I run a one way ANOVA for the klak$season, i get an p=0.0274 * and for klak$year an p=0.63.

Is it appropriate to substitute the 2way anova for the 2 separate one way ANOVA if I cannont calculate the p value, because of the degrees of freedom?
 

rogojel

TS Contributor
#7
Hi,
if you use + instead of the * in the function call, you get a model without the interaction term. Other then that your output seems completely ok to me, what is the problem with it?

regards
rogojel
 

ivn

New Member
#8
The problem appears when using the same dataset in statistica and spss, because i don't get the p values and f test, mainly because of the reasons Miner said. That's why I'm not sure if the R results are correct