Announcement

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

  • Question: t-stat sum of coefficients

    I would like to know how to do t-statistic testing the null hypothesis that the sum if the coefficients on the two terms equals to 0.
    For example, I ran y = x1+x2+x3+x3*x4
    I would like to test that H0: x3+x3*x4 = 0.
    Thank you very much

  • #2
    There is one problem with your example: you excluded the main effect of x4. I assume this is a typo.

    There are several ways of doing this, here are 4:

    Code:
    // open example data
    sysuse auto
    
    // estimate the model
    reg price c.mpg##i.foreign i.rep78
    
    // see how the coefficients are called
    reg, coefl
    
    // test 1:
    test 1.foreign#c.mpg + mpg = 0
    
    // test 2:
    lincom 1.foreign#c.mpg + mpg
    
    // test 3:
    margins, dydx(mpg) over(foreign)
    
    // test 4:
    reg price c.mpg#ibn.foreign i.foreign i.rep78, hascons
    P.s. Posting under our real name has a long tradition on this list. We believe that it has contributed to a friendly and professional atmosphere on this list. It would be nice if you did the same by changing your login name to your real name. You can do so by using the "contact us" button at the bottom of every page.
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      yes, it's a typo. I'm changing my login name.
      cheers,

      Comment


      • #4
        Maarten Buis: Hi Maarten, I have a situation relating to exclusion of the main effect of a variable. I run a fixed effects model with interaction terms between a dummy variable BANK (1 for banks, 0 otherwise) like this (Hausman test indicates that fixed effects model is preferable for my data):

        xtreg lev i.BANK##(c.x1 c.x2 c.x2_square ) , fe vce(robust)
        1.BANK will be omitted because of collinearity. It means that we exclude the main effect of BANK. Is there any problem with my results where the main effect of BANK is excluded?

        After running the code, we have the following model:

        lev = a1*x1 + a2*x2 + a3*x2_square + a4*BANK*x1 + a5*BANK*x2 + a6*BANK*x2_square
        I want to know the estimated value "a2 + a3" (or the "total effect" of x2 and x2_square on the dependent variable). Am I right if I calcualte the sum of a2 and a3 then perform t-stat sum of coefficients as one of your suggestions:

        lincom x2 x2_square
        Last edited by Linh Nguyen; 30 Jun 2018, 02:59.
        --------------------
        (Stata 15.1 MP)

        Comment


        • #5
          Linh:
          -hausman- test with non-default standard errors is unfeasible.
          You should consider the user-written command -xtoverid- (-serach xtoverid-) if you invoke non-default standard errors.
          If you invoked cluster/robust standard errors after -hausman- outcome, your specification choice might be wrong (and your approach sounds methodologically flawed).
          Kind regards,
          Carlo
          (Stata 18.0 SE)

          Comment


          • #6
            Carlo Lazzaro: Thanks so much. I even don't know about this problem. I always invoke cluster standard errors after Hausman test.

            I run the following code:
            xtreg lev BANK x1 x2 x2_square BANK*x1 BANK*x2 BANK*x2_square, re cluster (id)
            xtoverid
            And the results:
            Test of overidentifying restrictions: fixed vs random effects
            Cross-section time-series model: xtreg re robust cluster(id)
            Sargan-Hansen statistic 609.953 Chi-sq(13) P-value = 0.0000
            It means that the following fixed effects model is better, doesn't it?
            xtreg lev i.BANK##(c.x1 c.x2 c.x2_square ) , fe vce(cluster id)
            If it's true, we exclude the main effect of BANK. Is there any problem with my results where the main effect of BANK is excluded?
            --------------------
            (Stata 15.1 MP)

            Comment


            • #7
              Linh:
              you're correct in interpreting the -xtoverid- output: go -fe-.
              As far as your second question is concerned, I fail to understand why you did not use -fvvarlist- (I know that -xtoverid- does not allow -fvvarlist- but your final code should go back to -fvvarlist- notation, especially if you plan to use -margins- and -marginsplot-).
              As an aside, please post the outcome table of your last code (using -fvvarlist- when necessary), so that interested listers can undestand the reason of you concern.
              Kind regards,
              Carlo
              (Stata 18.0 SE)

              Comment


              • #8
                Hi Carlo:
                It's my mistake. I forgot to use i.BANK in the first code. I should use the following code:
                xtreg lev i.BANK x1 x2 x2_square BANK*x1 BANK*x2 BANK*x2_square, re cluster (id)
                xtoverid
                And it doesn't work. Do you know which command I can use to test whether "fe vce(robust)" or "re vce(robust)" is preferable for my data?

                I have two sample: banks and non-bank firms, so I create a dummy variable BANK (1 for banks, 0 otherwise). My purpose is to examine the difference in leverage between banks and non-bank firms, as well as interaction terms between BANK and each factor (tangibility, profit). Hence, I use the following code:

                Code:
                . xtreg lev i.BANK##(c.tangibility c.profit c.profit_square), fe vce(robust)
                note: 1.BANK omitted because of collinearity
                
                Fixed-effects (within) regression               Number of obs     =     53,309
                Group variable: id                              Number of groups  =      4,356
                
                R-sq:                                           Obs per group:
                     within  = 0.0134                                         min =          1
                     between = 0.1883                                         avg =       12.2
                     overall = 0.1568                                         max =         17
                
                                                                F(6,4355)         =      31.80
                corr(u_i, Xb)  = 0.1840                         Prob > F          =     0.0000
                
                                                         (Std. Err. adjusted for 4,356 clusters in id)
                --------------------------------------------------------------------------------------
                                     |               Robust
                                 lev |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                ---------------------+----------------------------------------------------------------
                              1.BANK |          0  (omitted)
                         tangibility |   .1083819    .017238     6.29   0.000     .0745865    .1421772
                              profit |  -.0750669   .0084478    -8.89   0.000    -.0916288    -.058505
                       profit_square |  -.0294631   .0053349    -5.52   0.000    -.0399222    -.019004
                                     |
                  BANK#c.tangibility |
                                  1  |   .1565525   .0532894     2.94   0.003     .0520781     .261027
                                     |
                       BANK#c.profit |
                                  1  |   .9475515   .4493016     2.11   0.035     .0666917    1.828411
                                     |
                BANK#c.profit_square |
                                  1  |   -8.45701   5.230577    -1.62   0.106     -18.7116    1.797583
                                     |
                               _cons |   .1853595   .0042419    43.70   0.000     .1770433    .1936757
                ---------------------+----------------------------------------------------------------
                             sigma_u |  .17930011
                             sigma_e |  .11189022
                                 rho |  .71972253   (fraction of variance due to u_i)
                --------------------------------------------------------------------------------------
                
                . 
                end of do-file
                Because BANK is omitted, I focus my analysis on interaction terms BANK#factor. However, Maarten said that there is a problem if the main effect of a variable is excluded. Hence, I don't know whether my analysis is OK if I just focus on interaction terms.

                --------------------
                (Stata 15.1 MP)

                Comment


                • #9
                  Linh:
                  -being a bit old-fashioned, -xtoverid- does not allow -fvvarlist- notation.
                  The trick is using the -xi:- prefix, as you can see from the following toy-example:
                  Code:
                  . use "http://www.stata-press.com/data/r15/nlswork.dta"
                  (National Longitudinal Survey.  Young Women 14-26 years of age in 1968)
                  
                  . xtreg ln_wage i.race, re
                  
                  Random-effects GLS regression                   Number of obs     =     28,534
                  Group variable: idcode                          Number of groups  =      4,711
                  
                  R-sq:                                           Obs per group:
                       within  = 0.0000                                         min =          1
                       between = 0.0198                                         avg =        6.1
                       overall = 0.0186                                         max =         15
                  
                                                                  Wald chi2(2)      =      99.02
                  corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =     0.0000
                  
                  ------------------------------------------------------------------------------
                       ln_wage |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
                  -------------+----------------------------------------------------------------
                          race |
                        black  |  -.1300382    .013486    -9.64   0.000    -.1564702   -.1036062
                        other  |   .1011474   .0562889     1.80   0.072    -.0091768    .2114716
                               |
                         _cons |   1.691756   .0071865   235.41   0.000     1.677671    1.705841
                  -------------+----------------------------------------------------------------
                       sigma_u |  .38195681
                       sigma_e |  .32028665
                           rho |  .58714668   (fraction of variance due to u_i)
                  ------------------------------------------------------------------------------
                  
                  . xtoverid
                  1b:  operator invalid
                  r(198);
                  
                  . xi: xtreg ln_wage i.race, re
                  i.race            _Irace_1-3          (naturally coded; _Irace_1 omitted)
                  
                  Random-effects GLS regression                   Number of obs     =     28,534
                  Group variable: idcode                          Number of groups  =      4,711
                  
                  R-sq:                                           Obs per group:
                       within  = 0.0000                                         min =          1
                       between = 0.0198                                         avg =        6.1
                       overall = 0.0186                                         max =         15
                  
                                                                  Wald chi2(2)      =      99.02
                  corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =     0.0000
                  
                  ------------------------------------------------------------------------------
                       ln_wage |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
                  -------------+----------------------------------------------------------------
                      _Irace_2 |  -.1300382    .013486    -9.64   0.000    -.1564702   -.1036062
                      _Irace_3 |   .1011474   .0562889     1.80   0.072    -.0091768    .2114716
                         _cons |   1.691756   .0071865   235.41   0.000     1.677671    1.705841
                  -------------+----------------------------------------------------------------
                       sigma_u |  .38195681
                       sigma_e |  .32028665
                           rho |  .58714668   (fraction of variance due to u_i)
                  ------------------------------------------------------------------------------
                  
                  .
                  - what you're experiencing relates to -fe- machinery, that wipes out time-invariant predictors. In your case, in all likelihood a given firm will be forever bank or not, no matter how many times it is measured (that is, no matter how many waves of data you're going to collect). Hence, the only way to get a coefficient for BANK is to switch to the -re- specification (provided that -xtoverid- outcome will point you out to it).
                  Kind regards,
                  Carlo
                  (Stata 18.0 SE)

                  Comment


                  • #10
                    Carlo Lazzaro:

                    -xtoverid- indicates that fixed effects model is preferable for my data, so I can't get the coefficient for BANK. However, I have an idea. We know that xtreg and reg with dummy variables (i.idcode) create the same coefficients as follows:
                    Code:
                    . use http://www.stata-press.com/data/r13/nlswork
                    (National Longitudinal Survey.  Young Women 14-26 years of age in 1968)
                    
                    . keep if idcode <100 // just save time because idcode= 5159
                    (27,959 observations deleted)
                    
                    . eststo clear
                    
                    . eststo: qui xtreg ln_wage age ttl_exp tenure         ,fe vce(cluster idcode)
                    (est1 stored)
                    
                    . eststo: qui reg   ln_wage age ttl_exp tenure i.idcode,   vce(cluster idcode)
                    (est2 stored)
                    
                    . esttab *, b(3) t(3) scalars(r2) label star (* 0.10 ** 0.05 *** 0.01)
                    
                    ----------------------------------------------------
                                                  (1)             (2)   
                                         ln(wage/GN~)    ln(wage/GN~)   
                    ----------------------------------------------------
                    age in current year        -0.005          -0.005   
                                             (-0.488)        (-0.448)   
                    
                    total work experie~e        0.032**         0.032** 
                                              (2.391)         (2.196)   
                    
                    job tenure, in years        0.015**         0.015*  
                                              (2.003)         (1.840)   
                    
                    NLS ID=1                                    0.000   
                                                                  (.)   
                    
                    NLS ID=2                                   -0.423***
                                                            (-28.876)   
                    ...
                    Hence, I can get the coefficient of race (1 for black, 0 otherwise) with reg i.idcode as follows:
                    Code:
                    . eststo clear
                    
                    . eststo: qui xtreg ln_wage i.race age ttl_exp tenure         ,fe vce(cluster idcode)
                    (est1 stored)
                    
                    . eststo: qui reg   ln_wage i.race age ttl_exp tenure i.idcode,   vce(cluster idcode)
                    (est2 stored)
                    
                    . esttab *, b(3) t(3) scalars(r2) label star (* 0.10 ** 0.05 *** 0.01)
                    
                    ----------------------------------------------------
                                                  (1)             (2)   
                                         ln(wage/GN~)    ln(wage/GN~)   
                    ----------------------------------------------------
                    white                       0.000           0.000   
                                                  (.)             (.)   
                    
                    black                       0.000           0.010   
                                                  (.)         (0.222)   
                    
                    age in current year        -0.005          -0.005   
                                             (-0.488)        (-0.448)   
                    
                    total work experie~e        0.032**         0.032** 
                                              (2.391)         (2.196)   
                    
                    job tenure, in years        0.015**         0.015*  
                                              (2.003)         (1.840)   
                    
                    NLS ID=1                                    0.000   
                                                                  (.)   
                    
                    NLS ID=2                                   -0.423***
                                                            (-28.876)   
                    ...
                    The coefficient of black (0.01) suggests that the wage of black is 0.01% higher than that of while.

                    Accordingly, I have 2 questions:
                    1) Can I use -reg- with i.idcode to capture the effect of race on wage? Is there anything which I should consider?
                    2) Why are the t-statistics different between -xtreg- and -reg-?
                    --------------------
                    (Stata 15.1 MP)

                    Comment


                    • #11
                      Linh:
                      1) since you're interested in estimating a time-invariant coefficient but -xtoverid- points you out to -fe- specification (that wipes out time-invariant predictors), you can cansider going -re- with Mundlak correction (-search mundlak-);
                      2) you have different t-stat because your standard errors are different under -xtreg,fe- and -regress-.
                      Kind regards,
                      Carlo
                      (Stata 18.0 SE)

                      Comment


                      • #12
                        Carlo:
                        Could you please give me (some) reasons why we shouldn't replace -xtreg, fe- with -reg- with the id dummies (i.idcode)? Is it true if I say that adding the id dummies to my regression is unlikely to solve the problem of unobserved fixed effects?
                        --------------------
                        (Stata 15.1 MP)

                        Comment


                        • #13
                          Linh:
                          for the pooled OLS to be consistent, is required that the (composite) error terms is uncorrelated with the vector of regressors.
                          This restriction holds for -re- specification, but not for the -fe- one, where the panel-wise error is actually correlated with the vector of regressors.
                          Kind regards,
                          Carlo
                          (Stata 18.0 SE)

                          Comment


                          • #14
                            Thank you so much, Carlo!
                            --------------------
                            (Stata 15.1 MP)

                            Comment


                            • #15
                              Carlo Lazzaro: I read the help file of xtoverid:

                              is guaranteed always to generate a nonnegative test statistic.
                              Could you please explain why -xtoverid- always generates a nonnegative test statistic?

                              I post this question here becaue it relates to the above questions. If it not appropriate here, I will make a new threat.
                              --------------------
                              (Stata 15.1 MP)

                              Comment

                              Working...
                              X