Announcement

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

  • Manual calculation -- Sargan test

    I am trying to calculate the Sargan over identification test manually and am having trouble replicating the value from the output from ivreg2 or ivregress. My understanding is that the test is equal to N*R^2 from an equation predicting the second stage residuals with all exogenous variables (including instruments), and that this value is then distributed as chi-squared with df equal to the number of excess instruments.

    With the code below, I obtain a manual Sargan value that is much lower than the value produced from ivreg2 or ivregress. Can someone point out what I'm doing wrong?

    Thank you,
    Steve Finkel

    drop _all
    * Create 1000 observations
    set obs 1000

    * Create variables, [0-100)
    gen double X1 = 100*runiform()
    gen double X2 = 100*runiform()
    gen double z1 = 100*runiform()
    gen double z2 = 100*runiform()
    gen double u = 200*runiform()-100 /* unobservable */
    gen double e = 20*runiform()-10 /* residual */

    * DGP for first stage
    gen E = z1 + z2 + u

    * DGP for the outcome
    gen Y = E + X1 - X2 + (u + e)

    ** 1st stage
    reg E z1 z2 X1 X2
    predict E_hat
    predict cfunction, r

    ** Manual 2SLS
    reg Y E_hat X1 X2
    predict r2stage, r

    * Sargan
    reg r2stage X1 X2 z1 z2
    display e(r2)
    display e(N)*e(r2)
    display chi2tail((2-1),e(N)*e(r2))

    * Canned
    ivreg2 Y (E = z1 z2) X1 X2

    ivregress 2sls Y (E = z1 z2) X1 X2, first
    estat overid
Working...
X