实验设计与分析(第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)

相关推荐
生态学者14 小时前
香港理工大学Nature Communications:沿海塑料际古菌组特征及生态影响
大数据·人工智能·算法·r语言·微信公众平台
统计学小王子2 天前
数学建模国赛倒计时6天——《软件工具(R语言精讲)》
开发语言·数学建模·r语言
statistican_ABin2 天前
全球教育水平提升预测分析报告——基于R语言随机森林回归模型的全球40国1960-2020年教育水平预测研究
随机森林·回归·r语言
典典分享指南4 天前
用飞书多维表格搭建内容管理看板
java·python·r语言·composer·symfony
2601_962070236 天前
差异基因富集分析(R语言——GO&KEGG&GSEA)
开发语言·golang·r语言
统计学小王子7 天前
R语言入门——ggplot2图例增加公式
开发语言·r语言
统计学小王子9 天前
R语言入门——相关性热图(建模常用二)
r语言·可视化·相关性分析
知识分享小能手10 天前
概理论与数理统计学习教程,从入门到精通,在数理统计中应用R软件(22)
开发语言·学习·r语言
知识分享小能手11 天前
概理论与数理统计学习教程,从入门到精通,在数理统计中应用R软件(21)
开发语言·学习·r语言
asyxchenchong88816 天前
R语言混合效应(多水平/层次/嵌套)模型及贝叶斯实现技术应用
开发语言·r语言