8.1
Get the data .
I used the following Splus statement to read in the data:
data <- scan("radon.data",what=list(1,1,1,1))
# read in data from "radon.data" from the working directory
8.5
Get the data .
Ignore part (b).
Splus statements to read in the data and create the design matrix
(i.e., the "X" matrix):
###########################
# Get the data
###########################
d<-matrix(scan("table75.data"),ncol=7, byrow=T)
level _d[,1]
lactation_d[,2]
age _d[,3]
weight _d[,4]
dry _d[,5]
milk _d[,6]
fatpct _d[,7]
fat _milk*fatpct
add <- level*dry*1000 #grams of additive consumed
food <- add+dry
x1 <- ifelse(level==0, 1,0)
x2 <- ifelse(level==0.1,1,0)
x3 <- ifelse(level==0.2,1,0)
X <- cbind(level,lactation,age,weight) # design matrix X
###########################
# Regression of fat on X
#
###########################
bob<-lsfit(X,fat)
8.10
Get the data .
data <- scan("table83.data",what=list(1,1,1))
y <- log(data[[3]])
x <- log(data[[1]])