实验设计与分析(第6版,Montgomery)第5章析因设计引导5.7节思考题5.8 R语言解题

本文是实验设计与分析(第6版,Montgomery著,傅珏生译) 第5章析因设计引导5.7节思考题5.8 R语言解题。主要涉及方差分析,正态假设检验,残差分析,交互作用图。

(a)

dataframe<-data.frame(

Light=c(580,568,570,550,530,579,546,575,599,1090,1087,1085,1070,1035,1000,1045,1053,1066,1392,1380,1386,1328,1312,1299,867,904,889),

Temperature=gl(3,9,27),

Material=gl(3,3,27))

summary (dataframe)

dataframe.aov2 <- aov(Light~Material*Temperature,data=dataframe)

summary (dataframe.aov2)

> summary (dataframe.aov2)

Df Sum Sq Mean Sq F value Pr(>F)

Material 2 150865 75432 206.4 3.89e-13 ***

Temperature 2 1970335 985167 2695.3 < 2e-16 ***

Material:Temperature 4 290552 72638 198.7 1.25e-14 ***

Residuals 18 6579 366


Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

with(dataframe,interaction.plot(Temperature,Material,Light,type="b",pch=19,fixed=T,xlab="Temperature (°F)",ylab="Light"))

plot.design(Light~Material*Temperature,data=dataframe)

(b)

fit <-lm(Light~Material*Temperature,data=dataframe)

anova(fit)

> anova(fit)

Analysis of Variance Table

Response: Light

Df Sum Sq Mean Sq F value Pr(>F)

Material 2 150865 75432 206.37 3.886e-13 ***

Temperature 2 1970335 985167 2695.26 < 2.2e-16 ***

Material:Temperature 4 290552 72638 198.73 1.254e-14 ***

Residuals 18 6579 366


Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

summary(fit)

> summary(fit)

Call:

lm(formula = Light ~ Material * Temperature, data = dataframe)

Residuals:

Min 1Q Median 3Q Max

-35.000 -5.333 -0.333 6.667 35.000

Coefficients:

Estimate Std. Error t value Pr(>|t|)

(Intercept) 572.6667 11.0381 51.881 < 2e-16 ***

Material2 -19.6667 15.6102 -1.260 0.2238

Material3 0.6667 15.6102 0.043 0.9664

Temperature2 514.6667 15.6102 32.970 < 2e-16 ***

Temperature3 813.3333 15.6102 52.103 < 2e-16 ***

Material2:Temperature2 -32.6667 22.0762 -1.480 0.1562

Material3:Temperature2 -33.3333 22.0762 -1.510 0.1484

Material2:Temperature3 -53.3333 22.0762 -2.416 0.0265 *

Material3:Temperature3 -500.0000 22.0762 -22.649 1.11e-14 ***


Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 19.12 on 18 degrees of freedom

Multiple R-squared: 0.9973, Adjusted R-squared: 0.9961

F-statistic: 824.8 on 8 and 18 DF, p-value: < 2.2e-16

(c)

par(mfrow=c(2,2))

plot(fit)

par(mfrow=c(2,2))

plot(as.numeric(dataframeMaterial), fitresiduals, xlab="Material Type", ylab="Residuals", type="p", pch=16)

plot(as.numeric(dataframeTemperature), fitresiduals, xlab="Temperature", ylab="Residuals", pch=16)

相关推荐
全栈开发圈1 天前
干货分享|R语言聚类分析1
开发语言·r语言
AI科技星4 天前
空间光速螺旋动力学:统一质量、引力、电磁与时空本源的公理化理论与全现象验证
c语言·开发语言·opencv·算法·r语言
zhangfeng11338 天前
提示 R for Windows front-end 怎么被防火墙 阻止了 Rscript.exe` 和 `R.exe`区别
windows·r语言·php
全栈开发圈8 天前
新书速览|R语言医学数据分析与可视化
开发语言·数据分析·r语言
木与长清9 天前
人鼠同源基因离线转换
数据库·矩阵·数据分析·r语言
HP-Patience9 天前
【Rmarkdown】快速入门
r语言
HP-Patience9 天前
【Data Mining】01抽样技术
人工智能·数据挖掘·r语言
lihihi10 天前
P1650 [ICPC 2004 Shanghai R] 田忌赛马(同洛谷2587)
开发语言·算法·r语言
请叫我大虾10 天前
数据结构与算法-分裂问题,将数字分成0或1,求l到r之间有多少个1.
java·算法·r语言
MOON404☾10 天前
R语言EDA学习笔记
笔记·学习·数据分析·r语言·eda