LASSO methods
Predicted values for a provided matrix of predictors X
## S3 method for class 'LASSO' fitted(object, ...)
object |
An object of the class 'LASSO' returned either by the function 'lars2' or 'solveEN' |
... |
Other arguments: |
Returns a matrix that contains, for each value of lambda (in columns), the predicted values corresponding to each row of the matrix X
Marco Lopez-Cruz (maraloc@gmail.com) and Gustavo de los Campos
require(SFSI) data(wheatHTP) y = as.vector(Y[,"YLD"]) # Response variable X = scale(WL) # Predictors # Training and testing sets tst = 1:ceiling(0.3*length(y)) trn = seq_along(y)[-tst] # Calculate covariances in training set XtX = var(X[trn,]) Xty = cov(y[trn],X[trn,]) # Run the penalized regression fm = solveEN(XtX,Xty,alpha=0.5) # Predicted values yHat1 = fitted(fm, X=X[trn,]) # training data yHat2 = fitted(fm, X=X[tst,]) # testing data # Penalization vs correlation plot(-log(fm$lambda),cor(y[trn],yHat1)[1,], main="training") plot(-log(fm$lambda),cor(y[tst],yHat2)[1,], main="testing")
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.