Announcement

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

  • Testing a non-zero null hypothesis in a regression

    Hello,

    In my current project, I need to test whether a coefficient in my regression is significantly different from 1 (not from 0). I realize that I can obtain this information by simply running the regression and running a test on the coefficient afterwards, but I was hoping there would be a different method that actually incorporates this test into the regression table. This would be extrodinarily useful because I have been using esttab to create Latex tables from my regressions.

    My code is as follows:
    Code:
    eststo: xi: xtreg var1 var2 var3 i.year, fe 
    test var2 = 1
    .
    .
    .
    esttab using table.tex, drop(_Iyear*) stats(N) cells(b(star fmt(2)) se(par)) replace
    As is, this code produces a table in which coefficients are starred if they are significantly different from 0, and I can separately report whether the var2 coefficient is significantly different from 1. Is there any way that I can combine the regression and the test to automatically report the results of that test in the table itself?

    Any help would be very much appreciated.

    Thanks,
    Sarah

  • #2
    Code:
    gen y2 = var1 - var2
    reg y2 var2 var3
    This works for simple cases: does it work for yours?

    Comment


    • #3
      Brendan's code sounds right to me, except I wonder if it will zap other statistics of interest, e.g. in a regular regression things like R^2 and the model F get zapped when you do this.
      -------------------------------------------
      Richard Williams, Notre Dame Dept of Sociology
      StataNow Version: 19.5 MP (2 processor)

      EMAIL: [email protected]
      WWW: https://www3.nd.edu/~rwilliam

      Comment


      • #4
        I believe you could use an -estadd- after your -test- command.

        Here's an example:
        Code:
        sysuse auto, clear
        
        eststo m1: regress price weight length displacement
        
        test weight = 1
        estadd scalar pvalue = r(p)
        
        esttab m1 using table.tex, replace ///
            cells(b(star fmt(2)) se(par)) ///
            stats(pvalue N, fmt(3 0)) ///
            subs("pvalue" "p-value ($ H_0: \beta_{weight} = 1$)") label noabbrev
        And here's the table.tex returned:
        Code:
         
         {  
         \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}  
         \begin{tabular}{l*{1}{c}}  
         \hline\hline  
                             &\multicolumn{1}{c}{(1)}\\  
                             &\multicolumn{1}{c}{Price}\\  
                             &        b/se\\  
         \hline  
         Weight (lbs.)       &        4.61\sym{**} \\  
                             &      (1.40)         \\  
         Length (in.)        &      -97.63\sym{*}  \\  
                             &     (39.57)         \\  
         Displacement (cu. in.)&        0.73         \\  
                             &      (6.97)         \\  
         Constant            &    10440.63\sym{*}  \\  
                             &   (4369.32)         \\  
         \hline  
         p-value ($ H_0: \beta_{weight} = 1$)              &       0.012         \\  
         N                   &          74         \\  
         \hline\hline  
         \end{tabular}  
         }

        Comment

        Working...
        X