This post is solutions of the chapter 5 of `A Handbook of Statistical Analyses Using R, Second Edition'.
このポストはRによる統計解析ハンドブック(第2版)の第5章の解答になります。
1
Estimated values are larger than actual ones for pair of beef and low or that of cereal and high. Otherwise these are lower than that. B, C, L, H in the below graph stand for Beef, Cereal, Low and High.
牛肉で低たんぱく質、穀物で高たんぱく質は推定値が大きめになり、それ以外は推定値が低めに出ている。グラフ中のB、C、LとHはそれぞれBeef、Cereal、LowとHighの頭文字をとったものであることに注意。
data("weightgain", package="HSAUR2") resid <- weightgain$weightgain - aov(weightgain ~ source + type, data=weightgain)$fitted.values plot(resid, type="n", main="residuals") lab <- paste(abbreviate(weightgain[,1],minlength=1), abbreviate(weightgain[,2],minlength=1), sep="") text(resid, label=lab)
2
The result of plot.design shows no effect on gender and learner. So I conducted anova only with race and school. Race is only affects absent days in conclusion. Note that if anova is conducted with all vatiable, f-value of learner is smaller than 1 and it should be pooled.
plot.designからgender、learnerは関係なさそうとなる。そこで、人種、学年のみを使って分散分析を行った。結論としては欠席日数に効いているのは人種であると言える。なお、全変数で分散分析をかけると、learnerのF値が1より小さくプーリングすべきと考えられる。
data("schooldays", package="HSAUR2") plot.design(schooldays) aov.res <- aov(absent ~ race * school, data=schooldays) anova(aov.res) interaction.plot(schooldays$race, schooldays$school, schooldays$absent)
> anova(aov.res) Analysis of Variance Table Response: absent Df Sum Sq Mean Sq F value Pr(>F) race 1 2645.7 2645.65 12.4615 0.0005561 *** school 3 1325.5 441.85 2.0812 0.1052455 race:school 3 3738.2 1246.08 5.8693 0.0008221 *** Residuals 146 30996.7 212.31 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
3
By executing below code, we find that the hypothesis of the uniformity of mean values are rejected between any two groups.
以下のコードを実行すると、任意の2グループ間で、平均値の同等性の仮定は棄却されることが分かる。
data("students", package="HSAUR2") students.manova <- manova(cbind(low, high) ~ treatment, data=students) summary(students.manova, test="Hotelling-Lawley") # p-value is very small! summary.aov(students.manova) summary(manova(cbind(low, high) ~ treatment, data=students, subset = treatment %in% c("AA", "C"))) summary(manova(cbind(low, high) ~ treatment, data=students, subset = treatment %in% c("C", "NC"))) summary(manova(cbind(low, high) ~ treatment, data=students, subset = treatment %in% c("NC", "AA")))
0 件のコメント:
コメントを投稿