<$BlogRSDUrl$>

Saturday, October 04, 2008

Here is some code to do ridge predictions. Basically I add a column of one's and delete the newAccounts column before multiplication with the coefficient vector. If someone has a better way to do this, please post it. D.

foo<-read.table("http://www.stat.columbia.edu/~madigan/DM08/BankSortedMissing.TXT",header=TRUE)

bankTrain<-foo[1:200,]
bankTest<-foo[201:233,]
nTest <- dim(bankTest)[1]

mylm<-lm.ridge(newAccounts ~ .,data=bankTrain,lambda=10)
myPred<-as.matrix(cbind(rep(1,nTest),subset(bankTest,select=-newAccounts))) %*% coef(mylm)

This page is powered by Blogger. Isn't yours?