0

如果我考虑相同的线性模型,我不明白为什么 aov 和 anova 会提供不同的结果。我首先使用aov函数执行此操作:

res.aov <- aov(mRNA ~ Time, data= ID1.4.5.6.7)
summary(res.aov)

输出是:

Df Sum Sq Mean Sq F value Pr(>F)  
Time         1  0.263 0.26332   6.228 0.0146 *
Residuals   83  3.509 0.04228                 
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

然后我使用anova函数执行此操作:

model0 <- lm(mRNA ~ 1, data=ID1.4.5.6.7)
model1 <- lm(mRNA ~ Time, data=ID1.4.5.6.7)
model3 <- lm(mRNA ~ Time + Gene , data=ID1.4.5.6.7)
anova_df <- anova(model0,model1,model3)

anova_df[,"model"] <- c("Intercept","Time","Time+Gene")
anova_df
anova(model0,model1,model3)

输出如下:

Analysis of Variance Table

Model 1: mRNA ~ 1
Model 2: mRNA ~ Time
Model 3: mRNA ~ Time + Gene
  Res.Df    RSS Df Sum of Sq      F    Pr(>F) model
1     84 3.7727                                   1
2     83 3.5094  1   0.26332 7.2152 0.0088083     2
3     79 2.8831  4   0.62629 4.2902 0.0034166     3

所以首先我不明白为什么对于模型 mRNA~Time,我们得到不同的F值和不同的p 值?(aov 函数分别给出 6.228 和 0.0146,而 anova 7.2152 和 0.0088083)。

其次,如果我写这行代码:

anova_df[,"model"] <- c("Intercept","Time","Time+Gene")

为什么它不在输出数据框的列模型下打印名称“Intercept”、“Time”和“Time+Gene”?

我的数据集:

structure(list(Gene = c("ID-1", "ID-1", "ID-1", "ID-1", "ID-1", 
"ID-1", "ID-1", "ID-1", "ID-1", "ID-1", "ID-1", "ID-1", "ID-1", 
"ID-1", "ID-1", "ID-4", "ID-4", "ID-4", "ID-4", "ID-4", "ID-4", 
"ID-4", "ID-4", "ID-4", "ID-4", "ID-4", "ID-4", "ID-4", "ID-4", 
"ID-4", "ID-4", "ID-5", "ID-5", "ID-5", "ID-5", "ID-5", "ID-5", 
"ID-5", "ID-5", "ID-5", "ID-5", "ID-5", "ID-5", "ID-5", "ID-5", 
"ID-5", "ID-5", "ID-5", "ID-5", "ID-6", "ID-6", "ID-6", "ID-6", 
"ID-6", "ID-6", "ID-6", "ID-6", "ID-6", "ID-6", "ID-6", "ID-6", 
"ID-6", "ID-6", "ID-6", "ID-6", "ID-6", "ID-6", "ID-7", "ID-7", 
"ID-7", "ID-7", "ID-7", "ID-7", "ID-7", "ID-7", "ID-7", "ID-7", 
"ID-7", "ID-7", "ID-7", "ID-7", "ID-7", "ID-7", "ID-7", "ID-7"
), mRNA = c(-0.181385669, -0.059647494, 0.104476117, -0.052190978, 
-0.040484945, 0.194226742, -0.501601326, 0.102342605, -0.127143845, 
-0.008523742, -0.102946211, -0.042894028, 0.002922923, -0.134394347, 
-0.214204393, -0.138122686, 0.203242361, 0.097935502, 0.147068146, 
-0.089430917, 0.331565412, -0.034572422, -0.129896329, 0.324191, 
0.470108479, -0.027268223, 0.232304713, 0.090348708, 0.070848402, 
0.181540708, -0.502255367, -0.267631441, -0.368647839, -0.040910404, 
-0.003983171, -0.003983171, -0.003983171, -0.14980589, -0.119449612, 
-0.309154214, -0.487589361, 0.272803506, -0.421733575, -0.467108567, 
0.024868338, -0.156025729, -0.044680175, -0.206716896, -0.272014193, 
-0.230499883, -0.238597397, -0.118130949, 0.349957464, 0.349957464, 
0.349957464, 0.172048587, -0.186226994, 0.16113822, -0.293029136, 
-0.111636253, -0.044189887, 0.081555274, -0.048106079, -0.05853566, 
0.010407814, -0.066981809, -0.09828484, -0.315190986, -0.005102456, 
0.221556197, 0.206584568, 0.206584568, 0.206584568, 0.102649006, 
-0.011777384, -0.36963487, -0.054853074, -0.230240699, -0.210508323, 
-0.208889919, -0.050763372, 0.023073782, -0.095118984, -0.091076071, 
-0.330257395), Time = c(2, 2, 2, 3, 3, 2, 3, 3, 4, 4, 4, 4, 5, 
5, 5, 2, 2, 2, 3, 3, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 2, 2, 2, 
1, 1, 1, 3, 3, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 2, 2, 2, 1, 1, 1, 
3, 3, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 2, 2, 2, 1, 1, 1, 3, 2, 3, 
3, 4, 4, 4, 4, 5, 5, 5, 5), predicted_mRNA = c(-0.00551000342030954, 
-0.00551000342030954, -0.00551000342030954, -0.0302695238715682, 
-0.0302695238715682, -0.00551000342030954, -0.0302695238715682, 
-0.0302695238715682, -0.0550290443228268, -0.0550290443228268, 
-0.0550290443228268, -0.0550290443228268, -0.129307605676603, 
-0.129307605676603, -0.129307605676603, -0.00551000342030954, 
-0.00551000342030954, -0.00551000342030954, -0.0302695238715682, 
-0.0302695238715682, -0.00551000342030954, -0.0302695238715682, 
-0.0302695238715682, -0.0550290443228268, -0.0550290443228268, 
-0.0550290443228268, -0.0550290443228268, -0.129307605676603, 
-0.129307605676603, -0.129307605676603, -0.129307605676603, -0.00551000342030954, 
-0.00551000342030954, -0.00551000342030954, 0.0192495170309491, 
0.0192495170309491, 0.0192495170309491, -0.0302695238715682, 
-0.0302695238715682, -0.00551000342030954, -0.0302695238715682, 
-0.0302695238715682, -0.0550290443228268, -0.0550290443228268, 
-0.0550290443228268, -0.129307605676603, -0.129307605676603, 
-0.129307605676603, -0.129307605676603, -0.00551000342030954, 
-0.00551000342030954, -0.00551000342030954, 0.0192495170309491, 
0.0192495170309491, 0.0192495170309491, -0.0302695238715682, 
-0.0302695238715682, -0.00551000342030954, -0.0302695238715682, 
-0.0302695238715682, -0.0550290443228268, -0.0550290443228268, 
-0.0550290443228268, -0.0550290443228268, -0.129307605676603, 
-0.129307605676603, -0.129307605676603, -0.00551000342030954, 
-0.00551000342030954, -0.00551000342030954, 0.0192495170309491, 
0.0192495170309491, 0.0192495170309491, -0.0302695238715682, 
-0.00551000342030954, -0.0302695238715682, -0.0302695238715682, 
-0.0550290443228268, -0.0550290443228268, -0.0550290443228268, 
-0.0550290443228268, -0.129307605676603, -0.129307605676603, 
-0.129307605676603, -0.129307605676603)), row.names = c(NA, -85L
), class = "data.frame")
4

0 回答 0