Announcement

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

  • Use variable labels in the coefpath graph after lasso estimation

    I am trying to plot the coefficient paths after running a lass command. I am surprised that I cannot seem to find an option to display my variable labels rather than variable names. Is this not possible?

    Here is a reproducible example:

    Code:
    sysuse auto
    
    lasso linear price mpg rep78
    
    coefpath, legend(on)
    That produces this:
    Graph.png


    But I would like this:
    Graph.png

  • #2
    Code:
    coefpath, ///
        legend(on col(1)  /// 
        lab( 1 `: var lab mpg ') /// help legend_options##labelinfo
        lab( 2 `: var lab rep78 ') /// help macro##macro_fcn 
        )
        
    * the `: var lab mpg ' evaluates to the result of the macro function var lab

    Comment


    • #3
      Hi Bjarte, thanks for the response. Your solution works but is not generalizable--I ended up doing something similar for my dataset, but it requires manually specifying the labels for every plot which is tedious. I could probably write some sort of loop that extracted the number of variables, and iterated the labeling, but this seems unnecessarily complicated.

      The helpfile for coefpath states that "any options other than by() documented in [G-3] twoway_options", and legend options helpfile states that "By default, the descriptive text for legends is obtained from the variable's variable label; see [D] label. If the variable has no variable label, the variable's name is used." This does not seem to be the case for this, though, correct?

      Comment


      • #4
        The defaults of -graph twoway- is not necessarily the default of programs using -graph twoway-.
        -coefpath- plot path of coefficients, using the names of the coefficients as default.

        Comment

        Working...
        X