regression - R: Error in lars(x = , y = , type = "lasso") -
i trying run lasso (least absolute shrinkage , selection operator) using lars
package in r. here dimension of data:
dim(y) : 235 50
dim(x) : 235 15
when running following:
library(lars) return = as.matrix(ret.ff.zoo) ### "y" data = as.matrix(df) ### "x" lasso <- lars(data, return, type = c("lasso"))
i following error:
> lasso <- lars(data, return, type = c("lasso")) error in cvec - gamhat * gram[, active, drop = false] %*% w : non-conformable arrays
when make response variable "y" vector, follows:
lasso <- lars(data, return[,1], type = c("lasso"))
it works! however, doing means lasso performed on 1 security out of 3000 panel. how can formula extended analyze panel of data?? doing lasso separately on each of 3000 securities doesn't make sense excludes cross-sectional dynamic.
i use can get! thanks!
Comments
Post a Comment