Professional Documents
Culture Documents
Tutorial 10
Tutorial 10
Analysis
1.
2.
3.
4.
5.
6.
7.
Commands
#Factor variables
battery$Material <- factor(battery$Material)
battery$Temp <- factor(battery$Temp)
#Ordering variables
battery$Material <ordered(battery$Material,c("1","2","3"))
battery$Temp <- ordered(battery$Temp,c("15","70","125"))
#Defining contrasts
contrasts(battery$Material) <- contr.sum(3)
contrasts(battery$Temp) <- contr.sum(3)
#Fitting the model
yfit <- lm(Life~Temp*Material,data=battery)
summary(yfit)
#Checking assumptions
qqnorm(resid(yfit))
plot(as.numeric(battery$Temp),resid(yfit))
plot(as.numeric(battery$Material),resid(yfit))
plot(fitted(yfit),resid(yfit))
Report Sample
Introduction
Company Fake makes batteries with long life that can be exposed to extreme
temperature changes.
An experiment was conducted to investigate if different materials produce
different expected life for batteries regarding distinct temperatures. And if any of
these three materials performs better. The materials considered are: type1, type
2 and type 3, and the temperature levels considered are: 15, 70 and 125 F.
Methods
A linear regression model was fitted, regarding Material and Temperature and
their interaction. These predictors were considered as factors.
Model Yijk = mu + Ti + Bj + (TB)ij +Eijk
Results
In the model adequacy checking no deviations from normality were observed.
Some mild suggestions of non equal variances were observed indicating that
outliers could be present, but after checking with the company it was confirmed
that they were right observations.
As the experiment was randomized in all the possible phases the assumption of
independence is assumed to be hold.
Anova table for battery data
Analysis of Variance Table
Response: Life
Terms added sequentially (first to last)
Df Sum of Sq Mean Sq F Value
Pr(F)
Temp 2 39118.72 19559.36 28.96769 0.00000019
Material 2 10683.72 5341.86 7.91137 0.00197608
Temp:Material 4
9613.78 2403.44 3.55954 0.01861117
Residuals 27 18230.75
675.21
There was some evidence of an interaction effect between material type and
temperature level (p=0.019). The next plot gives an idea about how they interact
with each other.
160
140
Material
100
60
80
mean of Life
120
3
1
2
15
70
125
Temp
Material type 3 gives the best results if the interest is to achieve less loss of
effective life as the temperature changes.
In this analysis is possible to make multiple comparison of means response for
different levels of material and temperature, and in this way check more formally
the differences in levels of combination material-temperature.
Appendix
Model
Call: lm(formula = Life ~ Temp * Material, data = battery)
Residuals:
Min
1Q Median
3Q
Max
-60.75 -14.63
Coefficients:
(Intercept)
Temp1
Temp2
Material1
Material2
Temp1Material1
Temp2Material1
Temp1Material2
Temp2Material2
t value
24.3668
-3.5114
-6.7532
-3.6510
0.4581
-2.6829
1.8120
0.0833
-2.0172
Pr(>|t|)
0.0000
0.0016
0.0000
0.0011
0.6506
0.0123
0.0811
0.9342
0.0537