Announcement

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

  • Understanding lasso error code

    Dear all,
    consider the following example:
    Code:
    . clear all
    
    . version 18.0
    
    . set seed 123
    
    . webuse nlswork
    (National Longitudinal Survey of Young Women, 14-24 years old in 1968)
    
    . lasso linear age c_city not_smsa collgrad, nolog
    
    Lasso linear model                          No. of obs        =     28,502
                                                No. of covariates =          3
    Selection: Cross-validation                 No. of CV folds   =         10
    
    --------------------------------------------------------------------------
             |                                No. of      Out-of-      CV mean
             |                               nonzero       sample   prediction
          ID |     Description      lambda     coef.    R-squared        error
    ---------+----------------------------------------------------------------
           1 |    first lambda    1.074371         0       0.0001     44.90159
          60 |   lambda before    .0044393         3       0.0353     43.32257
        * 61 | selected lambda    .0040449         3       0.0353     43.32256
    --------------------------------------------------------------------------
    * lambda selected by cross-validation.
    Note: Minimum of CV function not found; lambda selected based on stop()
          stopping criterion.
    
    . di _rc
    601
    Apparently, the code runs fine and there are no error messages. Also, on the left side on the screen, after running lasso, there is no error code displayed for this command. Yet, _rc holds an error code. When I look up the code (601), this is: file not found (https://www.stata.com/manuals/perror.pdf#perror)

    I am a bit confused what is going on. Is here an error? And if so, what exactly? Which file is not found?
    Best wishes

    Stata 18.0 MP | ORCID | Google Scholar

  • #2
    Stata's return code _rc (and c(rc)) is set by capture, and is not reset when a program calling it (capture) exits.

    You should only check the value of _rc (or c(rc)) after using capture. Since you did not prefix lasso with capture, the value of _rc has no context for you.

    Comment


    • #3
      Thanks a ton for the clarification!
      Best wishes

      Stata 18.0 MP | ORCID | Google Scholar

      Comment

      Working...
      X