library(nlme)
library(car)
d1<- read.csv("/Users/koho0/Desktop/1st ANOVA stats/Fig 1_2hr interval_mEPSC freq_5day.csv")
str(d1)
## 'data.frame': 52 obs. of 4 variables:
## $ subject : int 1 2 3 4 5 6 7 8 9 10 ...
## $ sex : Factor w/ 2 levels "female","male": 2 2 2 2 2 2 2 2 2 2 ...
## $ group : Factor w/ 2 levels "con","sevo2": 1 1 1 1 1 1 1 1 1 1 ...
## $ mEPSC_freq: num 0.0417 0.1333 0.1417 0.1083 0.0667 ...
d1.gr=groupedData(d1[,4]~group|sex, data=d1)
plot(d1.gr, outer=~sex*group)
md1=aov(d1[,4]~group*sex, data=d1)
summary(md1)
## Df Sum Sq Mean Sq F value Pr(>F)
## group 1 0.0199 0.01988 2.738 0.1045
## sex 1 0.0442 0.04420 6.088 0.0172 *
## group:sex 1 0.0008 0.00080 0.111 0.7408
## Residuals 48 0.3485 0.00726
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
According to the results,
par(mfrow=c(2,2))
plot(md1)
comma <- function(x) format(x, digits = 4)
SWT=shapiro.test(residuals(md1))
LT=leveneTest(md1)
Pswt=comma(SWT$p.value)
Plt=comma(LT[1,3])
Accoring to the results, the p value of Shapiro-Wilk test is 1.963e-05, which is smaller than 0.05, so normality assumption canโt be accepted. The p-value of Levene test is 0.556, which is greater than 0.05, so equal variances can be assumed.
We use nested model for post hoc test(to compare group within each sex). There are only one test, so we do not use p-value adjustment.
nest=summary(lm(d1[,4]~sex/group, data=d1))
nest$coefficients
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.07500000 0.02459656 3.049207 0.003727391
## sexmale 0.05059524 0.03351946 1.509429 0.137744303
## sexfemale:groupsevo2 0.03571429 0.03351946 1.065479 0.291989518
## sexmale:groupsevo2 0.05148810 0.03351946 1.536066 0.131088395
According to the results,