Questions tagged [lars]
22 questions
12
votes
2 answers
Using LASSO in R with categorical variables
I've got a dataset with 1000 observations and 76 variables, about twenty of which are categorical. I want to use LASSO on this entire data set. I know that having factor variables doesn't really work in LASSO through either lars or glmnet, but the…

Alex
- 121
- 1
- 1
- 3
7
votes
1 answer
ValueError: A value in x_new is below the interpolation range
This is a scikit-learn error that I get when I do
my_estimator = LassoLarsCV(fit_intercept=False, normalize=False, positive=True, max_n_alphas=1e5)
Note that if I decrease max_n_alphas from 1e5 down to 1e4 I do not get this error any more.
Anyone…

Baron Yugovich
- 3,843
- 12
- 48
- 76
6
votes
1 answer
How to get the intercept from a linear model with lasso (lars R package)
I am having an hard time in getting the model estimated by the R package lars for my data.
For example I create a fake dataset x and corresponding values y like this:
x = cbind(runif(100),rnorm(100))
colnames(x) = c("a","b")
y = 0.5 + 3 * x[,1,drop…

lucacerone
- 9,859
- 13
- 52
- 80
6
votes
2 answers
Lasso r code - what is wrong with it?
I am attempting to carry out lasso regression using the lars package but can not seem to get the lars bit to work. I have inputted code:
diabetes<-read.table("diabetes.txt", header=TRUE)
diabetes
library(lars)
diabetes.lasso = lars(diabetes$x,…

math11
- 537
- 2
- 6
- 8
3
votes
2 answers
Error in cv.lars in R
I have a question regarding the cv.lars. Bellow there is a description for the data I use:
is.numeric(Y$Y1)
[1] TRUE
length(Y$Y1)
[1] 589
dim(Training_XX[7:ncol(Training_XX)])
[1] 589 5677
I have already run lasso using lars package. My code is…

Danai C.
- 125
- 4
- 8
2
votes
1 answer
"Error in rep(1, n) : invalid 'times' argument" when trying to run lars regression in R
I am trying to run a regression using lars in R. However, I keep getting this error :
Error in rep(1, n) : invalid 'times' argument.
Here's my code :
IN: dput(head(LBJ09))
OUT: structure(list(G = c("1", "2", "3", "4", "5", "6"), Date =…

twocentss
- 23
- 5
2
votes
1 answer
Error message when using predict with LARS model on testdata
I use a lars model and apply it to a large data set (75 features) with numerical data and factors.
I train the model by
mm <- model.matrix(target~0+.,data=data)
larsMod <- lars(mm,data$target,intercept=FALSE)
which gives a nice in-sample fit. If I…

Richi W
- 3,534
- 4
- 20
- 39
2
votes
1 answer
How to obtain coefficients from Lasso Regression in R?
Can someone tell me how to get the coefficients for lasso regression in package lars in R?
For example if the code is like:
test_lasso=lars(A,B)
Thank you.
user3999495
1
vote
0 answers
Model fit after inverse regression and forward stagewise on residuals
I work with prediction of height based on genetic information. The data is several hundred thousand data points from every organism, but a simplified version could be:
dput(df)
structure(list(ID = c("A", "B", "C", "D", "E"),
height = c(2, 4,…

Pardus
- 21
- 2
1
vote
0 answers
LARS "Lasso" regression not choosing significant explanatory variables
I am running lasso regression on a large data set n=1918, p=85 and the coefficients the regression identifies as important - when actually put into a linear model - are very insignificant. And one the other end, lasso deems very significant…

atosbar
- 35
- 6
1
vote
1 answer
I get this code for LARS but the variable seems undefined?
I got this code for LARS but when I run, it says undefined X. I can't understand what x is. Why is there an error?
function [beta, A, mu, C, c, gamma] = lars(X, Y, option, t, standardize)
% Least Angle Regression (LAR) algorithm.
% Ref: Efron et.…

user3593405
- 77
- 1
- 8
1
vote
1 answer
Using a loop to create matrices in R
I'm trying to do a leave-one-out cross-validation on a relatively small dataset (n = 22, p = 17) on a linear regression made from the LARS algorithm. Essentially I need to create n matrices of standardized data (each column consists of entries…

steven hurwitt
- 183
- 2
- 15
1
vote
0 answers
R: Error in lars(x = , y = , type = "lasso")
I am trying to run LASSO (least absolute shrinkage and selection operator) using the lars package in R. Here is the dimension of my data:
dim(y) : 235 50
dim(x) : 235 15
When running the following:
library(lars)
return = as.matrix(ret.ff.zoo) …

Mayou
- 8,498
- 16
- 59
- 98
1
vote
1 answer
Lasso path [linear_model.lars_path(model = 'lasso')]
I am confused about the behavior of the lasso path when running linear_model.lars_path(model = 'lasso') in scikit-learn.
I thought that once a weight (coefficient) becomes active (diff from 0) it must remain active during all the forthcoming steps…

user2043236
- 71
- 1
- 4
0
votes
0 answers
ELM based on LARS algorithm: IndexError: too many indices for array: array is 2-dimensional, but 3 were indexed
I want to combine the extreme learning machine (ELM) algorithm with the LARS algorithm. I adapted the code below for this. Unfortunately I will not be able to share the dataset for data privacy reasons. All other part of the code is below. Any help…