Announcement

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

  • Post r^2 and p-value to frame

    Hi all,

    I have a question that (should) have a fairly straightforward solution. I have code that looks like this:

    Code:
    frame create results  str30 (outcome ind_var) float (b_ se_)
    
    cwf data 
    
    local varlist x1 x2 x3
    
    reg outcome `varlist'
    foreach x in `varlist' {
        frame post results ("outcome") ("`x'") (_b[`x']) (_se[`x'])
    }
    
    cwf results
    browse
    This works great. However, I'd also like to store the r^2 and p-values, but I can't find any information about them in the documentation. Is there a way to call the p-value and r^2 for each variable `x', in the same way that _b[`x'] calls the coefficient? Thanks!

  • #2
    R-squared is model-specific, so it cannot be for each regressor.

    Code:
    frame create results  str30 (outcome ind_var) float (b_ se_ r2 p)
    
    cwf data
    
    local varlist x1 x2 x3
    
    reg outcome `varlist'
    foreach x in `varlist' {
        frame post results ("outcome") ("`x'") (_b[`x']) (_se[`x']) (`=e(r2)') (`=r(table)["pvalue", "`x'"]')
    }
    
    cwf results
    browse

    Comment


    • #3
      Thank you so much, Andrew! A reasonable explanation that worked perfectly. Cheers.

      Comment

      Working...
      X