Closed bran1685 closed 7 years ago
I am struggling with creating the Z matrix for problem 5 and solving for the parameters. I presently have the following for the y and Z matrices-
y=matrix(homeworkdat$Ozone, nrow=1)
fit=lm(Ozone ~ -1 + region, data=homeworkdat) Z=rbind(c(1,0,1,0,1), c(0,1,0,1,0))
I can't get the solve to run (solve(t(Z)%%Z)%%t(Z)%*%y) and I figure it's because I'm not setting the Z matrix up properly. Can anyone help?
Yep! Here's the answer I think,
fit=lm(Ozone ~ -1 + region, data=homeworkdat) Z = model.matrix(fit)
d=t(Z) y%%t(d)%%solve(d%*%t(d))
d=Z y%%d%%solve(t(d)%*%d)
I am struggling with creating the Z matrix for problem 5 and solving for the parameters. I presently have the following for the y and Z matrices-
y=matrix(homeworkdat$Ozone, nrow=1)
fit=lm(Ozone ~ -1 + region, data=homeworkdat) Z=rbind(c(1,0,1,0,1), c(0,1,0,1,0))
I can't get the solve to run (solve(t(Z)%%Z)%%t(Z)%*%y) and I figure it's because I'm not setting the Z matrix up properly. Can anyone help?