library(GAD)
## 载入需要的程辑包:matrixStats
## 载入需要的程辑包:R.methodsS3
## R.methodsS3 v1.8.1 (2020-08-26 16:20:06 UTC) successfully loaded. See ?R.methodsS3 for help.
obs<- c(73,68,74,71,67,73,67,75,72,70,75,68,78,73,68,73,71,75,75,69)
obs
## [1] 73 68 74 71 67 73 67 75 72 70 75 68 78 73 68 73 71 75 75 69
chem <-c(rep(1,5),rep(2,5),rep(3,5),rep(4,5))
bolt <- rep(seq(1,5),4)
chem<-as.fixed(chem)
bolt<-as.fixed(bolt)
model<-lm(obs~chem+bolt)
gad(model)
## Analysis of Variance Table
##
## Response: obs
## Df Sum Sq Mean Sq F value Pr(>F)
## chem 3 12.95 4.317 2.3761 0.1211
## bolt 4 157.00 39.250 21.6055 2.059e-05 ***
## Residual 12 21.80 1.817
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
model2<-lm(obs~chem)
gad(model2)
## Analysis of Variance Table
##
## Response: obs
## Df Sum Sq Mean Sq F value Pr(>F)
## chem 3 12.95 4.3167 0.3863 0.7644
## Residual 16 178.80 11.1750
r1 <- c(73,68,74,71,67)
r2 <- c(73,67,75,72,70)
r3 <- c(75,68,78,73,68)
r4 <- c(73,71,75,75,69)
obs <- c(r1,r2,r3,r4)
dat1 <- cbind(obs,chem)
str(dat1)
## num [1:20, 1:2] 73 68 74 71 67 73 67 75 72 70 ...
## - attr(*, "dimnames")=List of 2
## ..$ : NULL
## ..$ : chr [1:2] "obs" "chem"
dat1 <- as.data.frame(dat1)
str(dat1)
## 'data.frame': 20 obs. of 2 variables:
## $ obs : num 73 68 74 71 67 73 67 75 72 70 ...
## $ chem: num 1 1 1 1 1 2 2 2 2 2 ...
dat1$chem <- as.factor(dat1$chem)
str(dat1)
## 'data.frame': 20 obs. of 2 variables:
## $ obs : num 73 68 74 71 67 73 67 75 72 70 ...
## $ chem: Factor w/ 4 levels "1","2","3","4": 1 1 1 1 1 2 2 2 2 2 ...
aov.model<-aov(obs~chem, data = dat1)
summary(aov.model)
## Df Sum Sq Mean Sq F value Pr(>F)
## chem 3 12.95 4.317 0.386 0.764
## Residuals 16 178.80 11.175
plot(aov.model)
boxplot(obs~chem,xlab="type/method",ylab="observation",main="Boxplot of Observations")
library(GAD)
obs<- c(73,68,74,71,67,73,67,75,72,70,75,68,78,73,68,73,71,75,75,69)
obs
chem <-c(rep(1,5),rep(2,5),rep(3,5),rep(4,5))
bolt <- rep(seq(1,5),4)
chem<-as.fixed(chem)
bolt<-as.fixed(bolt)
model<-lm(obs~chem+bolt)
gad
model2<-lm(obs~chem)
gad(model2)