1. Think of the body as consisting of chunks stacked on top of each other. A person's height is the sum of the heights of the chunks, so the CLT suggests overall height is normal. 2. library(regtools) data(mlb) print(cor(mlb[,4:6])) 3. myLm <- function(inputMatrix,yColNum) { x <- inputMatrix[,-yColNum] a <- cbind(1,x) apai <- solve(t(a) %*% a) apd <- t(a) %*% inputMatrix[,yColNum] apai %*% apd } pred <- function(betahat,newx) { t(betahat) %*% c(1,newx) } library(regtools) data(mlb) mlb1 <- as.matrix(mlb[,4:6]) z <- myLm(mlb1,2) print(z) print(pred(z,c(70,21))) 4. load('Hwk1.RData') library(qeML) ml100 <- ml100[,-4] # do our own holdout set.seed(9999) # so we are all on the same page idxs <- sample(1:nrow(ml100),1000) trn <- ml100[-idxs,] tst <- ml100[idxs,] mlout <- qeLin(trn,'V3',holdout=NULL) preds <- predict(mlout,tst[,-3]) preds <- round(preds) ratingValues <- as.numeric(names(table(ml100$V3))) preds <- pmin(preds,max(ratingValues)) preds <- pmax(preds,min(ratingValues)) mean(preds == tst$V3)