Announcement

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

  • Is it possible to only display regression results if a certain variable is significant?

    Hello Statalist community,

    Is it possible to only show regression results if a certain variable is significant? E.g., I would love to run 100 regressions at the same time in Stata – but then Stata “mutes” all of the output tables (i.e., doesn’t display the output tables) if that variable is not significant?

    I have to run robustness checks for an analysis but have a very high number of variables which I need to test as independent variable of interest. In my regression specification, I have 12 control variables (these 12 controls are the same in each model) – but for some weird reason I have ca. 1,000 different measures of my independent variable of interest. Thus, I will have to run my regression model ca. 1,000 times. Now to make it more manageable to run such a high number of regressions, I was wondering if there is any option in Stata to only show/ display regression results, when certain variables have a p-value < 0.05?

    I have googled about this issue, and found the estout/ esttab commands – but did not manage to figure out if these commands can be used for what I am looking for, sadly.

    Thus, I was wondering if you may have any ideas how to go about this issue: I.e., only display regression results if a certain variable is significant – and “mute” the output tables otherwise.

    I am running an IV/2SLS regression, with panel data, using a fixed effects approach. Theory suggests an inverse U-shaped relationship, thus I have two independent variables of interest (IV_linear IV_squared). I would love Stata to display regression results only if both of these two independent variables (IV_linear and IV_squared) are significant, i.e., the p-value of these two variables is < 0.05.

    My model looks roughly like the below, and as mentioned above, I have ca. 1,000 ways of measuring IV_linear:

    Code:
     xtivreg DV control_1 control_2 control_3 DV control_4 control_5 control_6 DV control_7 control_8 control_9 DV control_10 control_11 control_12 (IV_linear IV_squared = Z_linear Z_squared), fe vce(cluster FirmID)
    Thank you so much in advance for any help or insights on this issue,

    Franz
    Last edited by Franz Hopp; 13 Mar 2022, 12:43.

  • #2
    The following example may start you in a useful direction.
    Code:
    sysuse auto, clear
    foreach iv of varlist weight headroom {
        quietly regress price `iv' 
        matrix r = r(table)
        if r["pvalue","`iv'"] < .01 {
            display _newline "`iv' is significant"
            regress // replay the regression output
        }
        else display _newline "`iv' not significant"
    }
    Code:
    weight is significant
    
          Source |       SS           df       MS      Number of obs   =        74
    -------------+----------------------------------   F(1, 72)        =     29.42
           Model |   184233937         1   184233937   Prob > F        =    0.0000
        Residual |   450831459        72  6261548.04   R-squared       =    0.2901
    -------------+----------------------------------   Adj R-squared   =    0.2802
           Total |   635065396        73  8699525.97   Root MSE        =    2502.3
    
    ------------------------------------------------------------------------------
           price | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
          weight |   2.044063   .3768341     5.42   0.000     1.292857    2.795268
           _cons |  -6.707353    1174.43    -0.01   0.995     -2347.89    2334.475
    ------------------------------------------------------------------------------
    
    headroom not significant

    Comment

    Working...
    X