R-Exercise 12b
# For the data in R-exercise 12 on the gun data we could be interested in predicting the rounds given specified levels of method, physique and team.
# and find confidence interval for estimated expected values as well as prediction intervals for new observations given the levels of these factors.
# a) Set up a data frame for values where you would like to make predictions, e.g.
testdata=data.frame(method=factor(c(1,2,1,2)), phys=factor(c(1,1,2,3)), team=factor(c(1,2,3,1)))
# Then find fitted/predicted values for your favourite model gfitfav from R-exercise 12 by
predict(gfitfav , newdata=testdata)
# b)
# Then obtain confidence intervals for the expected values at this levels of the factors by
predict(gfitfav , newdata=testdata, interval="confidence")
# Next find the corresponding prediction intervals by
predict(gfitfav , newdata=testdata, interval="prediction")
# Compare and discuss the difference between the confidence and prediction intervals.