Description Usage Arguments Author(s) Examples
Returns the predicted values for each value of lambda (in columns) for each row of the provided matrix X
1 2 |
object |
An object of the class 'LASSO' returned either by 'lars2' or 'solveEN' functions |
... |
Other arguments: a matrix |
Marco Lopez-Cruz (lopezcru@msu.edu) and Gustavo de los Campos
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | require(SFSI)
data(wheatHTP)
y = scale(Y[,"YLD"]) # Response variable
X = scale(WL) # Reflectance data
# Training and testing sets
tst = sample(seq_along(y),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 an Elastic-Net 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")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.