Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • logistic regression LASSO LASSOPACK

    Hi,

    I have successfully used rlassologit to obtain a parsimonious set of predictors in a logistic regression.
    rlassologit is a function from the LASSOPACK user written Stata package.

    https://statalasso.github.io/docs/la...log-1-citation

    I am attempting to use the LASSOPACK cross validation function for the same model but obtain the following error message

    type mismatch: exp.exp: transmorphic found where struct expected
    r(3000);


    The code I am using is as follows -

    cvlassologit dep_var indep_var1 - indep_var30, long postresults nfolds(3) seed(42) tabfold stratified


    I have chosen nfolds(3) as it is a small data set, n = 122 with a high proportion of cases (low proportion of controls).

    Before the error message appears I obtain the following output which verifies the folds.

    dep_var | Fold
    | 1 2 3 | Total
    -----------+---------------------------------+----------
    0 | 5 6 6 | 17
    1 | 35 35 35 | 105
    -----------+---------------------------------+----------
    Total | 40 41 41 | 122



    I am using Stata 13.

    Can anyone tell me what I need to do to run cvlassologit or is the problem to do with the low number of controls in each fold?

    Thanks in advance,

    Don

  • #2
    You didn't get a quick answer. You'll increase your chances of a helpful answer by following the FAQ on asking questions - provide Stata code in code delimiters, readable Stata output, and sample data using dataex. We don't even know exacty what you are running.

    Recent Stata includes a lasso capability (and a separate "manual" on lasso). With a user written procedure, an answer particularly for such errors depends on someone active really using that procedure. I'd suggest looking at Stata 16 or contacting the program's authors.

    Comment


    • #3
      Don, could you tell me which version you are using (type "which lassologit"). The lastest version can be installed using:

      Code:
      net install lassopack, from("https://raw.githubusercontent.com/statalasso/lassopack/master/lassopack_v13/") replace
      If this doesn't help, maybe you can send me a minimal example or your data (via email) and I will try to find the reason for this.

      Best

      Achim
      --
      Tag me or email me for ddml/pdslasso/lassopack/pystacked related questions. I don't check Statalist.

      Comment


      • #4
        Thanks Achim and Phil for taking time to consider this.

        Achim - I have installed the latest version but I still get the same error message. I am running Stata/IC 13.1

        I will send you a sample of the data as you proposed in a following email.

        Many thanks again,

        Don

        Comment


        • #5
          Hi Achim,

          Thanks for contacting me about this. You are correct. - cvlassologit doesn't run with Stata 13.1 IC but it worked well with Stata 15.

          Do you know of any package in Stata or elsewhere that can apply a lasso penalty in a multinomial regression?

          ​​​​​​​Don

          Comment


          • #6
            We have identified the problem and will release a new version soon.

            I am not aware of a multinomial lasso in Stata. (glmnet in R or sklearn in Python can do multinomial regression with L1 and L2 penalization.)
            --
            Tag me or email me for ddml/pdslasso/lassopack/pystacked related questions. I don't check Statalist.

            Comment


            • #7
              I was aware of glmnet. Thanks again for your assistance - very much appreciated

              Don

              Comment


              • #8
                FYI, you can install the latest version of lassologit as follows:

                Code:
                net install lassopack, from("https://raw.githubusercontent.com/statalasso/lassopack/master/lassopack_v131/")
                --
                Tag me or email me for ddml/pdslasso/lassopack/pystacked related questions. I don't check Statalist.

                Comment


                • #9
                  Thanks for that Achim.

                  I have another question if that is OK - for a given lambda what method is used to calculate the standard errors for the estimated coefficients?

                  Comment


                  • #10
                    Which standard errors are you referring to?
                    --
                    Tag me or email me for ddml/pdslasso/lassopack/pystacked related questions. I don't check Statalist.

                    Comment


                    • #11
                      After running cvlassologit, I run lassologit with lambda selected from cvlassologit.
                      After lassologit I obtain the coefficient estimates and their SE with e(beta_std)

                      quietly cvlassologit dep_var ///
                      indep_var1 - indep_var2, long postresults nfolds(3) tabfold stratified

                      lassologit dep_var ///
                      indep_var1 - indep_var31, long postresults lambda(`e(lopt)')

                      e(beta_std)

                      Comment


                      • #12
                        Hi Achim,

                        I just realised I was mistaken. The e(beta_std) are the coefficients for the standardized variables.
                        I understand that standard errors are not useful for penalized coefficients due to the bias introduced by the penalization.
                        However, do you think it is feasible to calculate standard errors conditioned on the penalty?

                        If yes (or maybe), could this be done with a bootstrap based on random subsets of the data and then calculating an average of the coefficients for a particular variable with its standard error?

                        Comment


                        • #13
                          For those interested, there is also an implementation of LASSO for ordinal regression in the R package glmnetcr.

                          Comment

                          Working...
                          X