Questions tagged [lasso-regression]

Lasso regression is a form of regression analysis used for variable selection and regularization. Use this tag for programming questions related to Lasso regression only. You can ask statistical questions on Cross Validated instead

457 questions
6
votes
1 answer

How does glmnet handle NA values?

How does glmnet in the R package 'glmnet' handle NA values? Or can it not tolerate NA values?
theforestecologist
  • 4,667
  • 5
  • 54
  • 91
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
5
votes
1 answer

Tuning a LASSO model and predicting using tidymodels

I want to perform penalty selection for the LASSO algorithm and predict outcomes using tidymodels. I will use the Boston housing dataset to illustrate the problem. library(tidymodels) library(tidyverse) library(mlbench) data("BostonHousing") dt <-…
Augustin
  • 307
  • 2
  • 10
5
votes
0 answers

Calculating the ridge parameter for given ridge estimates

Suppose response and covariate data are below: (1.4, 0.0), (1.4, -2.0), (0.8, 0.0), (0.4,2.0). I want to find the ridge parameter k, for which the ridge estimates are (1, -1/8) by applying the penalty parameter to slope.
5
votes
1 answer

Why grpreg library and gglasso library in R are giving different results for group LASSO?

I have been trying to do unsupervised feature selection using LASSO (by removing class column). The dataset includes categorical (factor) and continuous (numeric) variables. Here is the link. I built a design matrix using model.matrix() which…
5
votes
3 answers

glmnet error (nulldev == 0) stop("y is constant; gaussian glmnet fails at standardization step")

I am running the following (truncated) code using glmnet in R # do a lot of things to create the design matrix called x.design > glmnet(x.design, y, thresh=1e-11) where x.design is a n x p design matrix where n > p and y is a n x 1 vector of…
NM_
  • 1,887
  • 3
  • 12
  • 27
5
votes
0 answers

Difference between rqPen and quantreg packages in R

I am building a quantile regression model + LASSO penalization for the boston housing data in R. I found 2 packages that can build this kind of models: rqPen and quantreg. rqPen implements a cross validation process to tune the LASSO parameter…
5
votes
1 answer

Why calculating MSE in lasso regression gives different outputs?

I am trying to run different regression models on the Prostate cancer data from the lasso2 package. When I use Lasso, I saw two different methods to calculate the mean square error. But they do give me quite different results, so I would want to…
4
votes
1 answer

Panel Lasso Estimation in R

I have many continuous independent variables and a dependent dummy variable in my data set about individuals in given years. I want to perform feature selection using Logistic Random Effects Lasso/Logistic Fixed Effects Lasso. However, the default…
4
votes
2 answers

Nested resampling + LASSO (regr.cvglment) using mlr

I am trying to conduct nested resampling with 10 CVs for the inner and 10 CVs for the outer loop using regr.cvglment. Mlr provides the code using a wrapper function (https://mlr-org.github.io/mlr/articles/tutorial/devel/nested_resampling.html) Now,…
Sarah
  • 137
  • 9
4
votes
1 answer

Plotting lasso beta coefficients

I wrote this lasso code in R, and I got some beta values: #Lasso library(MASS) library(glmnet) Boston=na.omit(Boston) x=model.matrix(crim~.,Boston)[,-1] rownames(x)=c() y=as.matrix(Boston$crim) lasso.mod =glmnet(x,y, alpha =1, lambda =…
Majk
  • 87
  • 1
  • 9
4
votes
2 answers

Scoring Metric for scikit-learn's LassoCV

I'm using scikit-learn's LassoCV function. During cross-validation, what scoring metric is being used by default? I would like cross-validation to be based on "Mean squared error regression loss". Can one use this metric with LassoCV? One can…
4
votes
0 answers

How to plot ROC-curve in sklearn for LASSO method?

I want to compare lasso with other classifiers in sklearn. I have a binary outcome vector y. I usually compute a vector probas that contains the predicted probability for each input point to have 1 as a phenotype and then generate a ROC curve fro…
Fringant
  • 525
  • 1
  • 5
  • 17
4
votes
0 answers

Implementing lasso regression using TensorFlow

I want to run Lasso regression using TensorFlow. As the Lasso regression is simply adding L1-norm to the cost, I am going to define my cost term as cost = RSS + tf.nn.l1_norm(Weight) or cost = RSS + tf.reduce_sum(tf.abs(Weight)) train =…
emerson
  • 153
  • 1
  • 8
1
2
3
30 31