Announcement

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

  • Saving only significant results to excel, with 'n.s.' for the non significant results

    Hi all,

    I am running multiple regressions at once and I wanted to only look at the significant results, instead of going through each regression table to check which one is significant. I have able to do this however I am struggling to meaningfully export it to excel. Ideally, I would want to export the coefficients for the significant results and show a "n.s." in the cells which are not significant.

    Below is my current code, though this only outputs significant results. Any help on how to use eststo to store string values when the 'if' condition is not satisfied, will be really helpful!

    Code:
    local i=1
    foreach dv in dv1 dv2 dv3 {
        quiet reg `dv' IV //simple regression
        matrix r =r(table)
        if r["pvalue","IV"] < .05 {
            display _newline "IV's impact on `dv' is significant"
            regres //replay regression
            eststo linear`i' //store the significant regression result
            }
        else eststo linear`i="n.s." //this line is what I ideally want to do but of course eststo will not save a string value like this.
      estout * using test.xls,title ("DV:`dv'") cells(b(star fmt(3))) append unstack //only saves significant results
    clear results
    }
    Last edited by Neal Jha; 04 Sep 2022, 22:47.

  • #2
    Why would you want to have "n.s." in a table? Even if you do use tests of significance, you should mention the actual p-value. P over .05 does not imply no effect, and there is a huge difference between say p = .11 and p = 95.

    Comment


    • #3
      Hi Christopher,

      You are right - suppressing results like that does not make sense. I was trying to do this because my actual list of variables in quite long and I did not want to save every single output in excel. Though I can do that and then highlight all cells that have significant results. Probably that is a better solution than forcing everything to 'n.s.'. Thanks!

      Comment

      Working...
      X