Announcement

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

  • #16

    HTML Code:
    clear all
    input y x1 x2 x3
    99.2  96.7  101  12
    99  98.1  100.1  15
    100  100  100  17
    111.6  104.9  90.6  22
    122.2  104.9  86.5  36
    117.6  109.5  89.7  45
    121.1  110.8  90.6  66
    136  112.3  82.8  89
    154.2  109.3  70.1  99
    153.6  105.3  65.4  118
    158.5  101.7  61.3  134
    140.6  95.4  62.5  151
    136.2  96.4  63.6  167
    168  97.6  52.6  184
    154.3  102.4  59.7  200
    149  101.6  59.5  217
    165.5  103.8  61.3  233
    end
     reg y x1 x2 x3
     estat ovtest
    
     reg y x1 x2 x3
     predict double yh
     gen yh2 = yh^2
     gen yh3 = yh^3
     gen yh4 = yh^4
    
     reg y x1 x2 x3 yh2 yh3 yh4, noomitted
     test yh2 yh3 yh4

    HTML Code:
    . reg y x1 x2 x3
    
    Source | SS df MS Number of obs = 17
    -------------+------------------------------ F( 3, 13) = 84.64
    Model | 8461.08634 3 2820.36211 Prob > F = 0.0000
    Residual | 433.163821 13 33.3202939 R-squared = 0.9513
    -------------+------------------------------ Adj R-squared = 0.9401
    Total | 8894.25016 16 555.890635 Root MSE = 5.7724
    
    ------------------------------------------------------------------------------
    y | Coef. Std. Err. t P>|t| [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    x1 | 1.060841 .2769969 3.83 0.002 .4624256 1.659257
    x2 | -1.397391 .2321721 -6.02 0.000 -1.898969 -.895814
    x3 | -.0034456 .0514889 -0.07 0.948 -.1146807 .1077894
    _cons | 132.2612 36.46863 3.63 0.003 53.47554 211.0469
    ------------------------------------------------------------------------------
    
    . estat ovtest
    
    Ramsey RESET test using powers of the fitted values of y
    Ho: model has no omitted variables
    F(3, 10) = 3.94
    Prob > F = 0.0429
    HTML Code:
    .  reg y x1 x2 x3
    
          Source |       SS       df       MS              Number of obs =      17
    -------------+------------------------------           F(  3,    13) =   84.64
           Model |  8461.08634     3  2820.36211           Prob > F      =  0.0000
        Residual |  433.163821    13  33.3202939           R-squared     =  0.9513
    -------------+------------------------------           Adj R-squared =  0.9401
           Total |  8894.25016    16  555.890635           Root MSE      =  5.7724
    
    ------------------------------------------------------------------------------
               y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
              x1 |   1.060841   .2769969     3.83   0.002     .4624256    1.659257
              x2 |  -1.397391   .2321721    -6.02   0.000    -1.898969    -.895814
              x3 |  -.0034456   .0514889    -0.07   0.948    -.1146807    .1077894
           _cons |   132.2612   36.46863     3.63   0.003     53.47554    211.0469
    ------------------------------------------------------------------------------
    
    .  predict double yh
    (option xb assumed; fitted values)
    
    .  gen yh2 = yh^2
    .  gen yh3 = yh^3
    .  gen yh4 = yh^4
    .  reg y x1 x2 x3 yh2 yh3 yh4, noomitted
    
          Source |       SS       df       MS              Number of obs =      17
    -------------+------------------------------           F(  6,    10) =   73.05
           Model |  8695.85007     6  1449.30835           Prob > F      =  0.0000
        Residual |  198.400089    10  19.8400089           R-squared     =  0.9777
    -------------+------------------------------           Adj R-squared =  0.9643
           Total |  8894.25016    16  555.890635           Root MSE      =  4.4542
    
    ------------------------------------------------------------------------------
               y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
              x1 |  -72.75485   106.4014    -0.68   0.510     -309.832    164.3223
              x2 |    96.4665   140.1559     0.69   0.507    -215.8203    408.7533
              x3 |   .2020127    .347275     0.58   0.574    -.5717642    .9757895
             yh2 |    .795382   1.182519     0.67   0.516    -1.839436      3.4302
             yh3 |  -.0040173   .0061253    -0.66   0.527    -.0176653    .0096306
             yh4 |   7.64e-06   .0000118     0.65   0.531    -.0000186    .0000339
           _cons |  -6875.445   10117.14    -0.68   0.512    -29417.84    15666.95
    ------------------------------------------------------------------------------
    
    .  test yh2 yh3 yh4
    
     ( 1)  yh2 = 0
     ( 2)  yh3 = 0
     ( 3)  yh4 = 0
    
           F(  3,    10) =    3.94
                Prob > F =    0.0429
    .
    Emad A. Shehata
    Professor (PhD Economics)
    Agricultural Research Center - Agricultural Economics Research Institute - Egypt
    Email: [email protected]
    IDEAS: http://ideas.repec.org/f/psh494.html
    EconPapers: http://econpapers.repec.org/RAS/psh494.htm
    Google Scholar: http://scholar.google.com/citations?...r=cOXvc94AAAAJ

    Comment


    • #17
      any how the last code is not the optimal solution, the way to get the same results as Stata did is:

      HTML Code:
      clear all
       sysuse auto.dta
      *** Manual RESET
       gen double y = price
       gen double x1 = mpg
       reg y x1
       scalar r2=e(r2)
       predict double yh
       gen double yh2=yh^2
       gen double yh3=yh^3
       gen double yh4=yh^4
       reg y x1 yh2 yh3 yh4 , noomitted
       predict yhm4 , xb
       correlate yhm4 y
       scalar rho2=r(rho)*r(rho)
       scalar resetf4=(e(N)-e(df_m)-1)*(rho2-r2)/((4-1)*(1-rho2))
       scalar resetf4p= Ftail((4-1), (e(N)-e(df_m)-1), resetf4)
       scalar resetf4df= (e(N)-e(df_m)-1)
       
       reg y x1
       estat ovtest
       scalar list resetf4 resetf4df resetf4p
      Emad A. Shehata
      Professor (PhD Economics)
      Agricultural Research Center - Agricultural Economics Research Institute - Egypt
      Email: [email protected]
      IDEAS: http://ideas.repec.org/f/psh494.html
      EconPapers: http://econpapers.repec.org/RAS/psh494.htm
      Google Scholar: http://scholar.google.com/citations?...r=cOXvc94AAAAJ

      Comment


      • #18
        HTML Code:
        . clear all
        
        .
        .  sysuse auto.dta
        (1978 Automobile Data)
        
        .
        . *** Manual RESET
        
        .
        .  gen double y = price
        
        .
        .  gen double x1 = mpg
        
        .
        .  reg y x1
        
              Source |       SS       df       MS              Number of obs =      74
        -------------+------------------------------           F(  1,    72) =   20.26
               Model |   139449474     1   139449474           Prob > F      =  0.0000
            Residual |   495615923    72  6883554.48           R-squared     =  0.2196
        -------------+------------------------------           Adj R-squared =  0.2087
               Total |   635065396    73  8699525.97           Root MSE      =  2623.7
        
        ------------------------------------------------------------------------------
                   y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
                  x1 |  -238.8943   53.07669    -4.50   0.000    -344.7008   -133.0879
               _cons |   11253.06   1170.813     9.61   0.000     8919.088    13587.03
        ------------------------------------------------------------------------------
        
        .
        .  scalar r2=e(r2)
        
        .
        .  predict double yh
        (option xb assumed; fitted values)
        
        .
        .  gen double yh2=yh^2
        
        .
        .  gen double yh3=yh^3
        
        .
        .  gen double yh4=yh^4
        
        .
        .  reg y x1 yh2 yh3 yh4 , noomitted
        
              Source |       SS       df       MS              Number of obs =      74
        -------------+------------------------------           F(  4,    69) =   12.27
               Model |   263997367     4  65999341.7           Prob > F      =  0.0000
            Residual |   371068029    69  5377797.53           R-squared     =  0.4157
        -------------+------------------------------           Adj R-squared =  0.3818
               Total |   635065396    73  8699525.97           Root MSE      =    2319
        
        ------------------------------------------------------------------------------
                   y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
                  x1 |   4321.748   2876.026     1.50   0.137    -1415.767    10059.26
                 yh2 |   .0067004   .0040298     1.66   0.101    -.0013388    .0147396
                 yh3 |  -1.02e-06   5.56e-07    -1.83   0.072    -2.13e-06    9.20e-08
                 yh4 |   5.52e-11   2.71e-11     2.04   0.046     1.12e-12    1.09e-10
               _cons |  -182923.9   123551.7    -1.48   0.143    -429402.7    63555.01
        ------------------------------------------------------------------------------
        
        .
        .  predict yhm4 , xb
        
        .
        .  correlate yhm4 y
        (obs=74)
        
                     |     yhm4        y
        -------------+------------------
                yhm4 |   1.0000
                   y |   0.6447   1.0000
        
        
        .
        .  scalar rho2=r(rho)*r(rho)
        
        .
        .  scalar resetf4=(e(N)-e(df_m)-1)*(rho2-r2)/((4-1)*(1-rho2))
        
        .
        .  scalar resetf4p= Ftail((4-1), (e(N)-e(df_m)-1), resetf4)
        
        .
        .  scalar resetf4df= (e(N)-e(df_m)-1)
        
        .
        .   reg y x1
        
              Source |       SS       df       MS              Number of obs =      74
        -------------+------------------------------           F(  1,    72) =   20.26
               Model |   139449474     1   139449474           Prob > F      =  0.0000
            Residual |   495615923    72  6883554.48           R-squared     =  0.2196
        -------------+------------------------------           Adj R-squared =  0.2087
               Total |   635065396    73  8699525.97           Root MSE      =  2623.7
        
        ------------------------------------------------------------------------------
                   y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
                  x1 |  -238.8943   53.07669    -4.50   0.000    -344.7008   -133.0879
               _cons |   11253.06   1170.813     9.61   0.000     8919.088    13587.03
        ------------------------------------------------------------------------------
        
        .
        .  estat ovtest
        
        Ramsey RESET test using powers of the fitted values of y
               Ho:  model has no omitted variables
                          F(3, 69) =      7.72
                          Prob > F =      0.0002
        
        .
        .  scalar list resetf4 resetf4df resetf4p
           resetf4 =  7.7198817
         resetf4df =         69
          resetf4p =  .00016106
        
        .
        Emad A. Shehata
        Professor (PhD Economics)
        Agricultural Research Center - Agricultural Economics Research Institute - Egypt
        Email: [email protected]
        IDEAS: http://ideas.repec.org/f/psh494.html
        EconPapers: http://econpapers.repec.org/RAS/psh494.htm
        Google Scholar: http://scholar.google.com/citations?...r=cOXvc94AAAAJ

        Comment


        • #19
          HTML Code:
          . reset y x1
          ==============================================================================
          * Ordinary Least Squares (OLS)
          ==============================================================================
            y = x1
          ------------------------------------------------------------------------------
            Sample Size       =          74
            Wald Test         =     20.2584   |   P-Value > Chi2(1)       =      0.0000
            F-Test            =     20.2584   |   P-Value > F(1 , 72)     =      0.0000
           (Buse 1973) R2     =      0.2196   |   Raw Moments R2          =      0.8563
           (Buse 1973) R2 Adj =      0.2087   |   Raw Moments R2 Adj      =      0.8543
            Root MSE (Sigma)  =   2623.6529   |   Log Likelihood Function =   -686.5396
          ------------------------------------------------------------------------------
          - R2h= 0.2196   R2h Adj= 0.2087  F-Test =   20.26 P-Value > F(1 , 72)  0.0000
          - R2v= 0.2196   R2v Adj= 0.2087  F-Test =   20.26 P-Value > F(1 , 72)  0.0000
          ------------------------------------------------------------------------------
                     y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
          -------------+----------------------------------------------------------------
                    x1 |  -238.8943   53.07669    -4.50   0.000    -344.7008   -133.0879
                 _cons |   11253.06   1170.813     9.61   0.000     8919.088    13587.03
          ------------------------------------------------------------------------------
          ==============================================================================
          *** REgression Specification Error Tests (RESET)
          ==============================================================================
           Ho: Model is Specified  -  Ha: Model is Misspecified
          ------------------------------------------------------------------------------
          * Ramsey Specification ResetF Test
          - Ramsey RESETF1 Test: Y= X Yh2         =  12.937  P-Value > F(1,  71) 0.0006
          - Ramsey RESETF2 Test: Y= X Yh2 Yh3     =   9.098  P-Value > F(2,  70) 0.0003
          - Ramsey RESETF3 Test: Y= X Yh2 Yh3 Yh4 =   7.720  P-Value > F(3,  69) 0.0002
          ------------------------------------------------------------------------------
          * DeBenedictis-Giles Specification ResetL Test
          - Debenedictis-Giles ResetL1 Test       =   6.328  P-Value > F(2, 70)  0.0030
          - Debenedictis-Giles ResetL2 Test       =   6.707  P-Value > F(4, 68)  0.0001
          - Debenedictis-Giles ResetL3 Test       =   4.520  P-Value > F(6, 66)  0.0007
          ------------------------------------------------------------------------------
          * DeBenedictis-Giles Specification ResetS Test
          - Debenedictis-Giles ResetS1 Test       =   5.910  P-Value > F(2, 70)  0.0042
          - Debenedictis-Giles ResetS2 Test       =   3.845  P-Value > F(4, 68)  0.0071
          - Debenedictis-Giles ResetS3 Test       =   3.350  P-Value > F(6, 66)  0.0061
          ------------------------------------------------------------------------------
          - White Functional Form Test: E2= X X2  =   7.310  P-Value > Chi2(1)   0.0259
          ------------------------------------------------------------------------------
          .
          
          So, the following commands are not good idea to calculate Ramsey RESET test
          reg y x1 x2 x3 yh2 yh3 yh4
          test yh2 yh3 yh4
          Thanks for all
          Last edited by Emad Shehata; 02 May 2016, 11:30.
          Emad A. Shehata
          Professor (PhD Economics)
          Agricultural Research Center - Agricultural Economics Research Institute - Egypt
          Email: [email protected]
          IDEAS: http://ideas.repec.org/f/psh494.html
          EconPapers: http://econpapers.repec.org/RAS/psh494.htm
          Google Scholar: http://scholar.google.com/citations?...r=cOXvc94AAAAJ

          Comment


          • #20
            I think this is the critical section of ovtest.ado:
            Code:
                                    tempvar yh2 yh3 yh4
                                    summ `yh'
                                    replace `yh' = (`yh'-r(min))/(r(max)-r(min))
                                    gen float `yh2' = `yh'*`yh'
                                    gen float `yh3' = `yh'*`yh'*`yh'
                                    gen float `yh4' = `yh'*`yh'*`yh'*`yh'
                                    local rhs "`yh2' `yh3' `yh4'"
            The resulting variables then range between 0 and 1. Adapting that to the auto example,

            Code:
            sysuse auto.dta, clear
            reg price mpg
            estat ovtest
            predict double price_hat if e(sample)
            sum price_hat
            replace price_hat = (price_hat-r(min))/(r(max)-r(min))
            gen float price_hat2 = price_hat^2
            gen float price_hat3 = price_hat^3
            gen float price_hat4 = price_hat^4
            reg price mpg price_hat2 price_hat3 price_hat4
            test price_hat2 price_hat3 price_hat4
            At this point I would just trust ovtest rather than try to replicate by hand.



            -------------------------------------------
            Richard Williams, Notre Dame Dept of Sociology
            StataNow Version: 19.5 MP (2 processor)

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

            Comment


            • #21
              Dear Richard,

              I am afraid I disagree. As far as I know, the -ovtest- command does not allow us to choose the number of powers to use (3 is generally too much!) and does not allow us to perform the test using robust standard errors (which is generally desirable).

              Moreover, the RESET can be used in binary models (here is has nice interpretations), count data models, Tobit, and in all other models based on a linear index. There are no "ovtests" for all these models.

              What I find troubling is Stata's sensitivity to the scale of the dependent variable. For example, in many models you can get convergence or non-convergence simply by changing the scale of the dependent variable.

              All the best,

              Joao

              Comment


              • #22
                if we want to use test after regression , as mention of Prof. Richard
                We need some modification to be done in the predicted variable (yh)
                So, the following comands can be followed:


                HTML Code:
                *** Manual RESET
                 clear all
                 sysuse auto.dta
                 gen double y = price
                 gen double x1 = mpg
                 reg y x1
                 estat ovtest
                
                 predict double yh
                 summ yh
                 replace yh = (yh-r(min))/(r(max)-r(min))
                 gen double yh2=yh^2
                 gen double yh3=yh^3
                 gen double yh4=yh^4
                 reg y x1 yh2 yh3 yh4
                 test yh2 yh3 yh4


                HTML Code:
                 *** Manual RESET
                . qui {
                .  clear all
                .  sysuse auto.dta
                .  gen double y = price
                .  gen double x1 = mpg
                .  reg y x1
                .  }
                
                .  estat ovtest
                
                Ramsey RESET test using powers of the fitted values of y
                       Ho:  model has no omitted variables
                                  F(3, 69) =      7.72
                                  Prob > F =      0.0002
                . qui {
                .  predict double yh
                .  summ yh
                .  replace yh = (yh-r(min))/(r(max)-r(min))
                .  gen double yh2=yh^2
                .  gen double yh3=yh^3
                .  gen double yh4=yh^4
                .  reg y x1 yh2 yh3 yh4
                .  }
                
                .  test yh2 yh3 yh4
                 ( 1)  yh2 = 0
                 ( 2)  yh3 = 0
                 ( 3)  yh4 = 0
                
                       F(  3,    69) =    7.72
                            Prob > F =    0.0002
                Last edited by Emad Shehata; 02 May 2016, 12:13.
                Emad A. Shehata
                Professor (PhD Economics)
                Agricultural Research Center - Agricultural Economics Research Institute - Egypt
                Email: [email protected]
                IDEAS: http://ideas.repec.org/f/psh494.html
                EconPapers: http://econpapers.repec.org/RAS/psh494.htm
                Google Scholar: http://scholar.google.com/citations?...r=cOXvc94AAAAJ

                Comment

                Working...
                X