predict.slim {flare} | R Documentation |
Prediction for an object with S3 class "slim"
Description
Predicting responses of the given design data.
Usage
## S3 method for class 'slim'
predict(object, newdata, lambda.idx = c(1:3), Y.pred.idx = c(1:5), ...)
Arguments
object |
An object with S3 class |
newdata |
An optional data frame in which to look for variables with which to predict. If omitted, the traning data of the are used. |
lambda.idx |
The indices of the regularizaiton parameters in the solution path to be displayed. The default values are |
Y.pred.idx |
The indices of the predicted response vectors in the solution path to be displayed. The default values are |
... |
Arguments to be passed to methods. |
Details
predict.slim
produces predicted values of the responses of the newdata
from the estimated beta
values in the object
, i.e.
\hat{Y} = \hat{\beta}_0 + X_{new} \hat{\beta}.
Value
Y.pred |
The predicted response vectors based on the estimated models. |
Author(s)
Xingguo Li, Tuo Zhao, Lie Wang, Xiaoming Yuan and Han Liu
Maintainer: Xingguo Li <xingguo.leo@gmail.com>
See Also
slim
and flare-package
.
Examples
## load library
library(flare)
## generate data
set.seed(123)
n = 100
d = 200
d1 = 10
rho0 = 0.3
lambda = c(3:1)*sqrt(log(d)/n)
Sigma = matrix(0,nrow=d,ncol=d)
Sigma[1:d1,1:d1] = rho0
diag(Sigma) = 1
mu = rep(0,d)
X = mvrnorm(n=2*n,mu=mu,Sigma=Sigma)
X.fit = X[1:n,]
X.pred = X[(n+1):(2*n),]
eps = rt(n=n,df=n-1)
beta = c(rep(sqrt(1/3),3),rep(0,d-3))
Y.fit = X.fit%*%beta+eps
## Regression with "dantzig".
out=slim(X=X.fit,Y=Y.fit,lambda=lambda,method = "lq",q=1)
## Display results
Y=predict(out,X.pred)