Stat 401B Fall 2015 Lab #7 (Due October 22)

advertisement
Stat 401B Fall 2015 Lab #7 (Due October 22)
There is an R code set at the end of this lab and posted on the course web page that will prove useful
for doing this lab. Use it in answering/doing the following.
1. Consider an analysis of the SLR class example of an experiment done to study the effects of
x  uniaxial stress applied (kg/mm 2 )
on
y  time to fracture (hrs)
for specimens of 18-8 stainless steel immersed in 40% CaCl solution at 100 degrees C .
a) Make a scatterplot of the data.
b) Find the least squares line through the data, the sample correlation between x and y , and the
coefficient of determination for the SLR fit.
c) What are values of x and
n
x  x 
i 1
i
2
for this data set?
d) What is the value of sLF in this data set? Use this and make 95% two-sided confidence limits for
the standard deviation of time to fracture for any fixed stress (according to the SLR model).
d) Give 95% confidence limits for slope and intercept in the SLR model. Is it possible that time to
fracture doesn't change with stress? Explain.
e) Give an ANOVA table for SLR in the format presented in class.
f) Plot the data, the least squares line, 95% confidence limits for the mean time to fracture as a
function of stress, and 95% prediction limits for the next time to fracture one stress level at a time.
2. Consider an analysis of the hardness data set. For a particular alloy, the variables
x1  % Cu in the alloy, and
x2  tempering temperature
were studied as impacting a hardness measurement, y .
a) Fit an equation
yˆi  bo  b1 x1i  b2 x2i
1
to the data.
b) Under the normal multiple linear regression model involving predictors x1 and x2 , find two-sided
confidence limits for the standard deviation of hardness associated with any fixed pair of values
 x1 , x2  .
c) Find 95% two-sided confidence limits for the rates of change of mean hardness with respect to x1
and then x2 with the other predictor variable held fixed.
d) Find 95% two-sided confidence limits for the mean hardness when x1  .10 and x2  1100 .
Compare these to 95% prediction limits for the next hardness at this set of conditions.
e) Repeat part d) for the set of conditions x1  .02 and x2  1000 .
f) How do the lengths of the intervals from d) compare to those from e)? Why is this reasonable?
g) What about which residual plot(s) makes consideration of the relationship
y   0  1 x1   2 x2   3 x22
Seem like a good idea?
h) How do R 2 values compare without and with a quadratic effect of temperature?
i) Find 95% two-sided confidence limits for  3 in a model
yi   0  1 x1i   2 x2i   3 x22i   i
From these does it seem like a good idea to employ the additional (quadratic) term in modeling?
Code Set for Stat 401B Laboratory #7
#Here is code for the SLR Analysis of the Stress/Time-to-Failure Data
stress<-c(2.5,5.0,10.0,15.0,17.5,20.0,25.0,30.0,35.0,40.0)
failuretime<-c(63,58,55,61,62,37,38,45,46,19)
plot(stress,failuretime)
abline(lm(failuretime~stress))
cor(stress,failuretime)
2
mean(stress)
var(stress)*(length(stress)-1)
timefit1<-lm(failuretime~stress)
summary(timefit1)
aov(timefit1)
predict.lm(timefit1,se.fit=TRUE,interval="prediction",level=.95)
out1c<-predict.lm(timefit1,se.fit=TRUE,interval="confidence",level=.95)
out1p<-predict.lm(timefit1,se.fit=TRUE,interval="prediction",level=.95)
out1c
out1p
points(stress,out1c$fit[,2],type="l")
points(stress,out1c$fit[,3],type="l")
points(stress,out1p$fit[,2],type="l")
points(stress,out1p$fit[,3],type="l")
plot(timefit1)
#Here is some code for the MLR Analysis of the Hardness Data
pctcu<-c(rep(.02,4),rep(.1,4),rep(.18,4))
temp<-rep(c(1000,1100,1200,1300),3)
hardness<-c(78.9,65.1,55.2,56.4,80.9,69.7,57.4,55.4,85.3,71.8,60.7,58.9)
hardnessfit1<-lm(hardness~pctcu+temp)
summary(hardnessfit1)
3
aov(hardnessfit1)
plot(hardnessfit1)
hardnessfit1$coef
hardnessfit1$resid
plot(pctcu,hardnessfit1$resid)
plot(temp,hardnessfit1$resid)
tempsq<-temp^2
hardnessfit2<-lm(hardness~pctcu+temp+tempsq)
summary(hardnessfit2)
aov(hardnessfit2)
plot(hardnessfit2)
hardnessfit2$coef
hardnessfit2$resid
hardnessfit2$fitted.values
predict.lm(hardnessfit2,se.fit=TRUE,interval="prediction",level=.95)
plot(pctcu,hardnessfit2$resid)
plot(temp,hardnessfit2$resid)
plot(hardnessfit2$resid,hardness-hardnessfit2$fitted.values)
4
Download