1. 程式人生 > >R語言中的含一個組間因子和一個組內因子的重複測量方差分析

R語言中的含一個組間因子和一個組內因子的重複測量方差分析

我們關注寒帶植物。因變數是二氧化碳吸收量(uptake),單位為ml/L,自變數是植

物型別Type(魁北克VS密西西比州)和七種水平(95~1000 umol/m^2 sec)的二氧化碳濃度(conc)。另外,Type是組間因子,conc是組內因子

w1b1 <- subset(CO2, Treatment == "chilled")
fit <- aov(uptake ~ (conc * Type) + Error(Plant/(conc)), w1b1)
summary(fit)
Error: Plant
          Df Sum Sq Mean Sq F value  Pr(>F)   
Type       1 2667.2  2667.2   60.41 0.00148 **
Residuals  4  176.6    44.1                   
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


Error: Plant:conc
          Df Sum Sq Mean Sq F value   Pr(>F)    
conc       1  888.6   888.6  215.46 0.000125 ***
conc:Type  1  239.2   239.2   58.01 0.001595 ** 
Residuals  4   16.5     4.1                     
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


Error: Within
          Df Sum Sq Mean Sq F value Pr(>F)
Residuals 30    869   28.97  

par(las = 2)
par(mar = c(10, 4, 4, 2))
with(w1b1, interaction.plot(conc, Type, uptake, type = "b", 
    col = c("red", "blue"), pch = c(16, 18), main = "Interaction Plot for Plant Type and Concentration"))



boxplot(uptake ~ Type * conc, data = w1b1, col = (c("gold",  "green")), main = "Chilled Quebec and Mississippi Plants", ylab = "Carbon dioxide uptake rate (umol/m^2 sec)")