Description Usage Arguments Value Examples
View source: R/optimal_alphas.R
Title optimal alphas function
1 | optimal_alphas(x, w, y, grid_alphas, cont_folds, family)
|
x |
A matrix of variables to be selected by shrinkrage methods. |
w |
A matrix or vector of variables that cannot be selected(no shrinkrage). |
y |
response variable. |
grid_alphas |
a grid of alphas between 0 and 1. |
cont_folds |
Set TRUE for contiguous folds used in time depedent data. |
family |
The glmnet family. |
lambdas_opt a vector with the optimal alpha and lambda.
1 2 3 4 5 6 7 8 9 10 11 12 13 | set.seed(1)
data("stock_data")
data("news_data")
y=as.matrix(stock_data[1:200,2])
w=as.matrix(stock_data[1:200,3])
data("news_data")
X=news_data[1:200,2:ncol(news_data)]
x=as.matrix(X)
grid_alphas=seq(by=0.25,to=1,from=0.5)
cont_folds=TRUE
t=length(y)
optimal_alphas=optimal_alphas(x[1:(t-1),],
w[1:(t-1),],y[2:t],grid_alphas,TRUE,"gaussian")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.