How to obtain Confidence Intervals for a LASSO regression? The 2019 Stack Overflow Developer Survey Results Are InStandard errors for lasso prediction using RInference after using Lasso for variable selectionWhy is feature selection important, for classification tasks?Building reliable glmnet model and constructing predictionsHow can I implement lasso in R using optim functionR - Lasso Regression - different Lambda per regressorHow to interpret all zero coefficients in the results of cv.glmnet?Nested cross-validation with LASSO for model selection and evaluationglmnet returning lambda that gives all-zero coefficients as optimal lambdaLASSO: optimal $lambda$ drops all predictors from modelInference after using Lasso for variable selectionBuilding final model in glmnet after cross validationCOX model with Lasso using one dataset and predicting in a different dataset

Should I use my personal e-mail address, or my workplace one, when registering to external websites for work purposes?

Delete all lines which don't have n characters before delimiter

Shouldn't "much" here be used instead of "more"?

Apparent duplicates between Haynes service instructions and MOT

Sci-fi book where a human is taken from Earth to help man an alien ship in a fight against other aliens and rises through the ranks to command

How to notate time signature switching consistently every measure

Worn-tile Scrabble

Multiply Two Integer Polynomials

Why hard-Brexiteers don't insist on a hard border to prevent illegal immigration after Brexit?

Why isn't airport relocation done gradually?

Is a "Democratic" Feudal System Possible?

Why do UK politicians seemingly ignore opinion polls on Brexit?

Are there any other methods to apply to solving simultaneous equations?

How to manage monthly salary

What does Linus Torvalds mean when he says that Git "never ever" tracks a file?

Landlord wants to switch my lease to a "Land contract" to "get back at the city"

FPGA - DIY Programming

How can I autofill dates in Excel excluding Sunday?

Why didn't the Event Horizon Telescope team mention Sagittarius A*?

Is bread bad for ducks?

Is this app Icon Browser Safe/Legit?

Can you compress metal and what would be the consequences?

Loose spokes after only a few rides

What is the most effective way of iterating a std::vector and why?



How to obtain Confidence Intervals for a LASSO regression?



The 2019 Stack Overflow Developer Survey Results Are InStandard errors for lasso prediction using RInference after using Lasso for variable selectionWhy is feature selection important, for classification tasks?Building reliable glmnet model and constructing predictionsHow can I implement lasso in R using optim functionR - Lasso Regression - different Lambda per regressorHow to interpret all zero coefficients in the results of cv.glmnet?Nested cross-validation with LASSO for model selection and evaluationglmnet returning lambda that gives all-zero coefficients as optimal lambdaLASSO: optimal $lambda$ drops all predictors from modelInference after using Lasso for variable selectionBuilding final model in glmnet after cross validationCOX model with Lasso using one dataset and predicting in a different dataset



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2












$begingroup$


I'm very new from R. I have this code for a LASSO regression:



X <- X <- as.matrix(read.csv2("DB_LASSO_ERP.csv"))
y <- read.csv2("OUTCOME_LASSO_ERP.csv",header=F)$V1
fit <- glmnet(x = X, y = y, family = "binomial", alpha = 1)
crossval <- cv.glmnet(x = X, y = y, family = "binomial")
penalty <- crossval$
lambda.min
fit1 <- glmnet(x = X, y = y, family = "binomial", alpha = 1, lambda = penalty)


I want to obtain Confidence Intervals for this coefficients. How can I do? Can you help me with the script please? I have very few experience with R.
Thanks!










share|cite|improve this question







New contributor




Alfonso is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$







  • 1




    $begingroup$
    The answer here suggests that there is no consensus on how to calculate the standard errors of LASSO. Since you need the standard errors for confidence interval, you have to be very careful
    $endgroup$
    – V. Aslanyan
    6 hours ago






  • 1




    $begingroup$
    The link provided by @V.Aslanyan is quite useful, but note that the initial discussion on that page (from 2014) pre-dated much subsequent work on this topic.
    $endgroup$
    – EdM
    5 hours ago

















2












$begingroup$


I'm very new from R. I have this code for a LASSO regression:



X <- X <- as.matrix(read.csv2("DB_LASSO_ERP.csv"))
y <- read.csv2("OUTCOME_LASSO_ERP.csv",header=F)$V1
fit <- glmnet(x = X, y = y, family = "binomial", alpha = 1)
crossval <- cv.glmnet(x = X, y = y, family = "binomial")
penalty <- crossval$
lambda.min
fit1 <- glmnet(x = X, y = y, family = "binomial", alpha = 1, lambda = penalty)


I want to obtain Confidence Intervals for this coefficients. How can I do? Can you help me with the script please? I have very few experience with R.
Thanks!










share|cite|improve this question







New contributor




Alfonso is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$







  • 1




    $begingroup$
    The answer here suggests that there is no consensus on how to calculate the standard errors of LASSO. Since you need the standard errors for confidence interval, you have to be very careful
    $endgroup$
    – V. Aslanyan
    6 hours ago






  • 1




    $begingroup$
    The link provided by @V.Aslanyan is quite useful, but note that the initial discussion on that page (from 2014) pre-dated much subsequent work on this topic.
    $endgroup$
    – EdM
    5 hours ago













2












2








2


1



$begingroup$


I'm very new from R. I have this code for a LASSO regression:



X <- X <- as.matrix(read.csv2("DB_LASSO_ERP.csv"))
y <- read.csv2("OUTCOME_LASSO_ERP.csv",header=F)$V1
fit <- glmnet(x = X, y = y, family = "binomial", alpha = 1)
crossval <- cv.glmnet(x = X, y = y, family = "binomial")
penalty <- crossval$
lambda.min
fit1 <- glmnet(x = X, y = y, family = "binomial", alpha = 1, lambda = penalty)


I want to obtain Confidence Intervals for this coefficients. How can I do? Can you help me with the script please? I have very few experience with R.
Thanks!










share|cite|improve this question







New contributor




Alfonso is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$




I'm very new from R. I have this code for a LASSO regression:



X <- X <- as.matrix(read.csv2("DB_LASSO_ERP.csv"))
y <- read.csv2("OUTCOME_LASSO_ERP.csv",header=F)$V1
fit <- glmnet(x = X, y = y, family = "binomial", alpha = 1)
crossval <- cv.glmnet(x = X, y = y, family = "binomial")
penalty <- crossval$
lambda.min
fit1 <- glmnet(x = X, y = y, family = "binomial", alpha = 1, lambda = penalty)


I want to obtain Confidence Intervals for this coefficients. How can I do? Can you help me with the script please? I have very few experience with R.
Thanks!







regression confidence-interval lasso glmnet






share|cite|improve this question







New contributor




Alfonso is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|cite|improve this question







New contributor




Alfonso is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|cite|improve this question




share|cite|improve this question






New contributor




Alfonso is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 7 hours ago









AlfonsoAlfonso

111




111




New contributor




Alfonso is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Alfonso is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Alfonso is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







  • 1




    $begingroup$
    The answer here suggests that there is no consensus on how to calculate the standard errors of LASSO. Since you need the standard errors for confidence interval, you have to be very careful
    $endgroup$
    – V. Aslanyan
    6 hours ago






  • 1




    $begingroup$
    The link provided by @V.Aslanyan is quite useful, but note that the initial discussion on that page (from 2014) pre-dated much subsequent work on this topic.
    $endgroup$
    – EdM
    5 hours ago












  • 1




    $begingroup$
    The answer here suggests that there is no consensus on how to calculate the standard errors of LASSO. Since you need the standard errors for confidence interval, you have to be very careful
    $endgroup$
    – V. Aslanyan
    6 hours ago






  • 1




    $begingroup$
    The link provided by @V.Aslanyan is quite useful, but note that the initial discussion on that page (from 2014) pre-dated much subsequent work on this topic.
    $endgroup$
    – EdM
    5 hours ago







1




1




$begingroup$
The answer here suggests that there is no consensus on how to calculate the standard errors of LASSO. Since you need the standard errors for confidence interval, you have to be very careful
$endgroup$
– V. Aslanyan
6 hours ago




$begingroup$
The answer here suggests that there is no consensus on how to calculate the standard errors of LASSO. Since you need the standard errors for confidence interval, you have to be very careful
$endgroup$
– V. Aslanyan
6 hours ago




1




1




$begingroup$
The link provided by @V.Aslanyan is quite useful, but note that the initial discussion on that page (from 2014) pre-dated much subsequent work on this topic.
$endgroup$
– EdM
5 hours ago




$begingroup$
The link provided by @V.Aslanyan is quite useful, but note that the initial discussion on that page (from 2014) pre-dated much subsequent work on this topic.
$endgroup$
– EdM
5 hours ago










1 Answer
1






active

oldest

votes


















5












$begingroup$

Please think very carefully about why you want confidence intervals for the LASSO coefficients and how you will interpret them. This is not an easy problem.



The predictors chosen by LASSO (as for any feature-selection method) can be highly dependent on the data sample at hand. You can examine this in your own data by repeating your LASSO model-building procedure on multiple bootstrap samples of the data. If you have predictors that are correlated with each other, the specific predictors chosen by LASSO are likely to differ among models based on the different bootstrap samples. So what do you mean by a confidence interval for a coefficient for a predictor, say predictor $x_1$, if $x_1$ wouldn't even have been chosen by LASSO if you had worked with a different sample from the same population?



Despite this instability in feature selection, LASSO-based models can be useful for prediction. The selection of 1 from among several correlated predictors might be somewhat arbitrary, but the 1 selected serves as a rough proxy for the others and thus can lead to valid predictions. The quality of predictions from a LASSO model is typically of more interest than are confidence intervals for the coefficients. You can test the performance of your LASSO approach by seeing how well the models based on multiple bootstrapped samples work on the full original data set.



That said, there is recent work on principled ways to obtain confidence intervals and on related issues in inference after LASSO. This page and its links is a good place to start. The issues are discussed in more detail in Section 6.3 of Statistical Learning with Sparsity. There is also a package selectiveInference in R that implements these methods. But these are based on specific assumptions that might not hold in your data. If you do choose to use this approach, make sure to understand the conditions under which the approach is valid and exactly what those confidence intervals really mean. That statistical issue, rather than the R coding issue, is what is crucial here.






share|cite|improve this answer











$endgroup$













    Your Answer





    StackExchange.ifUsing("editor", function ()
    return StackExchange.using("mathjaxEditing", function ()
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    );
    );
    , "mathjax-editing");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "65"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );






    Alfonso is a new contributor. Be nice, and check out our Code of Conduct.









    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstats.stackexchange.com%2fquestions%2f402267%2fhow-to-obtain-confidence-intervals-for-a-lasso-regression%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    5












    $begingroup$

    Please think very carefully about why you want confidence intervals for the LASSO coefficients and how you will interpret them. This is not an easy problem.



    The predictors chosen by LASSO (as for any feature-selection method) can be highly dependent on the data sample at hand. You can examine this in your own data by repeating your LASSO model-building procedure on multiple bootstrap samples of the data. If you have predictors that are correlated with each other, the specific predictors chosen by LASSO are likely to differ among models based on the different bootstrap samples. So what do you mean by a confidence interval for a coefficient for a predictor, say predictor $x_1$, if $x_1$ wouldn't even have been chosen by LASSO if you had worked with a different sample from the same population?



    Despite this instability in feature selection, LASSO-based models can be useful for prediction. The selection of 1 from among several correlated predictors might be somewhat arbitrary, but the 1 selected serves as a rough proxy for the others and thus can lead to valid predictions. The quality of predictions from a LASSO model is typically of more interest than are confidence intervals for the coefficients. You can test the performance of your LASSO approach by seeing how well the models based on multiple bootstrapped samples work on the full original data set.



    That said, there is recent work on principled ways to obtain confidence intervals and on related issues in inference after LASSO. This page and its links is a good place to start. The issues are discussed in more detail in Section 6.3 of Statistical Learning with Sparsity. There is also a package selectiveInference in R that implements these methods. But these are based on specific assumptions that might not hold in your data. If you do choose to use this approach, make sure to understand the conditions under which the approach is valid and exactly what those confidence intervals really mean. That statistical issue, rather than the R coding issue, is what is crucial here.






    share|cite|improve this answer











    $endgroup$

















      5












      $begingroup$

      Please think very carefully about why you want confidence intervals for the LASSO coefficients and how you will interpret them. This is not an easy problem.



      The predictors chosen by LASSO (as for any feature-selection method) can be highly dependent on the data sample at hand. You can examine this in your own data by repeating your LASSO model-building procedure on multiple bootstrap samples of the data. If you have predictors that are correlated with each other, the specific predictors chosen by LASSO are likely to differ among models based on the different bootstrap samples. So what do you mean by a confidence interval for a coefficient for a predictor, say predictor $x_1$, if $x_1$ wouldn't even have been chosen by LASSO if you had worked with a different sample from the same population?



      Despite this instability in feature selection, LASSO-based models can be useful for prediction. The selection of 1 from among several correlated predictors might be somewhat arbitrary, but the 1 selected serves as a rough proxy for the others and thus can lead to valid predictions. The quality of predictions from a LASSO model is typically of more interest than are confidence intervals for the coefficients. You can test the performance of your LASSO approach by seeing how well the models based on multiple bootstrapped samples work on the full original data set.



      That said, there is recent work on principled ways to obtain confidence intervals and on related issues in inference after LASSO. This page and its links is a good place to start. The issues are discussed in more detail in Section 6.3 of Statistical Learning with Sparsity. There is also a package selectiveInference in R that implements these methods. But these are based on specific assumptions that might not hold in your data. If you do choose to use this approach, make sure to understand the conditions under which the approach is valid and exactly what those confidence intervals really mean. That statistical issue, rather than the R coding issue, is what is crucial here.






      share|cite|improve this answer











      $endgroup$















        5












        5








        5





        $begingroup$

        Please think very carefully about why you want confidence intervals for the LASSO coefficients and how you will interpret them. This is not an easy problem.



        The predictors chosen by LASSO (as for any feature-selection method) can be highly dependent on the data sample at hand. You can examine this in your own data by repeating your LASSO model-building procedure on multiple bootstrap samples of the data. If you have predictors that are correlated with each other, the specific predictors chosen by LASSO are likely to differ among models based on the different bootstrap samples. So what do you mean by a confidence interval for a coefficient for a predictor, say predictor $x_1$, if $x_1$ wouldn't even have been chosen by LASSO if you had worked with a different sample from the same population?



        Despite this instability in feature selection, LASSO-based models can be useful for prediction. The selection of 1 from among several correlated predictors might be somewhat arbitrary, but the 1 selected serves as a rough proxy for the others and thus can lead to valid predictions. The quality of predictions from a LASSO model is typically of more interest than are confidence intervals for the coefficients. You can test the performance of your LASSO approach by seeing how well the models based on multiple bootstrapped samples work on the full original data set.



        That said, there is recent work on principled ways to obtain confidence intervals and on related issues in inference after LASSO. This page and its links is a good place to start. The issues are discussed in more detail in Section 6.3 of Statistical Learning with Sparsity. There is also a package selectiveInference in R that implements these methods. But these are based on specific assumptions that might not hold in your data. If you do choose to use this approach, make sure to understand the conditions under which the approach is valid and exactly what those confidence intervals really mean. That statistical issue, rather than the R coding issue, is what is crucial here.






        share|cite|improve this answer











        $endgroup$



        Please think very carefully about why you want confidence intervals for the LASSO coefficients and how you will interpret them. This is not an easy problem.



        The predictors chosen by LASSO (as for any feature-selection method) can be highly dependent on the data sample at hand. You can examine this in your own data by repeating your LASSO model-building procedure on multiple bootstrap samples of the data. If you have predictors that are correlated with each other, the specific predictors chosen by LASSO are likely to differ among models based on the different bootstrap samples. So what do you mean by a confidence interval for a coefficient for a predictor, say predictor $x_1$, if $x_1$ wouldn't even have been chosen by LASSO if you had worked with a different sample from the same population?



        Despite this instability in feature selection, LASSO-based models can be useful for prediction. The selection of 1 from among several correlated predictors might be somewhat arbitrary, but the 1 selected serves as a rough proxy for the others and thus can lead to valid predictions. The quality of predictions from a LASSO model is typically of more interest than are confidence intervals for the coefficients. You can test the performance of your LASSO approach by seeing how well the models based on multiple bootstrapped samples work on the full original data set.



        That said, there is recent work on principled ways to obtain confidence intervals and on related issues in inference after LASSO. This page and its links is a good place to start. The issues are discussed in more detail in Section 6.3 of Statistical Learning with Sparsity. There is also a package selectiveInference in R that implements these methods. But these are based on specific assumptions that might not hold in your data. If you do choose to use this approach, make sure to understand the conditions under which the approach is valid and exactly what those confidence intervals really mean. That statistical issue, rather than the R coding issue, is what is crucial here.







        share|cite|improve this answer














        share|cite|improve this answer



        share|cite|improve this answer








        edited 5 hours ago

























        answered 6 hours ago









        EdMEdM

        22.3k23496




        22.3k23496




















            Alfonso is a new contributor. Be nice, and check out our Code of Conduct.









            draft saved

            draft discarded


















            Alfonso is a new contributor. Be nice, and check out our Code of Conduct.












            Alfonso is a new contributor. Be nice, and check out our Code of Conduct.











            Alfonso is a new contributor. Be nice, and check out our Code of Conduct.














            Thanks for contributing an answer to Cross Validated!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstats.stackexchange.com%2fquestions%2f402267%2fhow-to-obtain-confidence-intervals-for-a-lasso-regression%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Are there any AGPL-style licences that require source code modifications to be public? Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Force derivative works to be publicAre there any GPL like licenses for Apple App Store?Do you violate the GPL if you provide source code that cannot be compiled?GPL - is it distribution to use libraries in an appliance loaned to customers?Distributing App for free which uses GPL'ed codeModifications of server software under GPL, with web/CLI interfaceDoes using an AGPLv3-licensed library prevent me from dual-licensing my own source code?Can I publish only select code under GPLv3 from a private project?Is there published precedent regarding the scope of covered work that uses AGPL software?If MIT licensed code links to GPL licensed code what should be the license of the resulting binary program?If I use a public API endpoint that has its source code licensed under AGPL in my app, do I need to disclose my source?

            2013 GY136 Descoberta | Órbita | Referências Menu de navegação«List Of Centaurs and Scattered-Disk Objects»«List of Known Trans-Neptunian Objects»

            Button changing it's text & action. Good or terrible? The 2019 Stack Overflow Developer Survey Results Are Inchanging text on user mouseoverShould certain functions be “hard to find” for powerusers to discover?Custom liking function - do I need user login?Using different checkbox style for different checkbox behaviorBest Practices: Save and Exit in Software UIInteraction with remote validated formMore efficient UI to progress the user through a complicated process?Designing a popup notice for a gameShould bulk-editing functions be hidden until a table row is selected, or is there a better solution?Is it bad practice to disable (replace) the context menu?