search for: yhat_enet

Displaying 1 result from an estimated 1 matches for "yhat_enet".

2012 Mar 21
2
glmnet: obtain predictions using predict and also by extracting coefficients
...2,mean) trainSDs <- apply(data.train,2,sd) # create standardized test data data.test.std <- sweep(data.test, 2, trainMeans) data.test.std <- sweep(data.test.std, 2, trainSDs, "/") # fit training model myglmnet =cv.glmnet(data.train,y) # predictions by using predict function yhat_enet <- predict(myglmnet,newx=data.test, s="lambda.min") # attempting to get predictions by using coefficients beta <- as.vector( t(coef(myglmnet,s="lambda.min"))) testX <- cbind(1,data.test.std) yhat2 <- testX %*% beta # does not match plot(yhat2,yhat_enet)