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

相关推荐
兮兮能吃能睡2 天前
R语言术语(2)
开发语言·r语言
小火柴1232 天前
利用R绘制箱线图
开发语言·r语言
天桥下的卖艺者2 天前
R语言手搓一个计算生存分析C指数(C-index)的函数算法
c语言·算法·r语言
Tiger Z3 天前
《R for Data Science (2e)》免费中文翻译 (第10章) --- Exploratory data
r语言·数据科学·中文翻译
拓端研究室3 天前
视频讲解|Python遗传算法GA在车辆路径规划VRP数据优化中的应用
开发语言·人工智能·r语言
兮兮能吃能睡3 天前
资料片:R语言中常见的英文术语及其含义
开发语言·r语言
绵羊20234 天前
R语言绘制热图
开发语言·r语言
青铜弟弟5 天前
R语言利用Export包导出pptx格式的文件有错误的原因
开发语言·r语言
维维180-3121-14555 天前
R语言空间数据分析实战:机器学习预测、尺度转换与地统计建模
r语言·生态·环境·气象·气候·水文·地质
生信小窝5 天前
068B-基于R语言平台Biomod2集成模型的物种分布模型构建和数据可视化教程【2027】
开发语言·信息可视化·r语言