Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: ZINb with endogenous regressors


From   Rodolphe Desbordes <rodolphe.desbordes@strath.ac.uk>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   st: ZINb with endogenous regressors
Date   Wed, 25 Feb 2009 22:55:42 +0000

Dear all,

[I sent this message this morning (about 12h ago)  but it did not seem to have gone through. I am trying again. I deeply apologise if you have already received this message.]

In a paper that I am currently writing, I am using a ZINB model. I suspect that some of my regressors may be endogenous. Hence I have decided to correct for endogeneity using the non-linear IV method described in "Microeconomics using Stata" by Cameron and Trivedi.

1)

A) For the first part (probit model), I have modified the example given in chapter 17:  the conditional mean function is now    "mu = normal(Xb)"  (instead of "mu=exp(Xb)").



net from http://www.stata-press.com/data/mus

net install mus

net get mus
clear mata
use mus17data.dta, clear
capture drop cons docvis2 pred prnonzero
generate cons = 1
gen docvis2=(docvis==0)
local y docvis2
local xlist private medicaid age age2 educyr actlim totchr cons local zlist income ssiratio medicaid age age2 educyr actlim totchr cons

mata void pgmm(todo, b, y, X, Z, Qb, g, H)
  {
    Xb = X*b'

*******
    mu = normal(Xb)

*********

    h = Z'(y-mu)
    W = cholinv(cross(Z,Z))
    Qb = h'W*h
    if (todo == 0) return
    G = -(mu:*Z)'X
    g = (G'W*h)'
    if (todo == 1) return
    H = G'W*G
    _makesymmetric(H)
   }
  st_view(y=., ., "`y'")
  st_view(X=., ., tokens("`xlist'"))
  st_view(Z=., ., tokens("`zlist'"))
  S = optimize_init()
  optimize_init_which(S,"min")
  optimize_init_evaluator(S, &pgmm())
  optimize_init_evaluatortype(S, "d2")
  optimize_init_argument(S, 1, y)
  optimize_init_argument(S, 2, X)
  optimize_init_argument(S, 3, Z)
  optimize_init_params(S, J(1,cols(X),0))
  optimize_init_technique(S,"nr")
  b = optimize(S)
  // Compute robust estimate of VCE
  Xb = X*b'

*********

  mu = normal(Xb)

*********

  h = Z'(y-mu)
  W = cholinv(cross(Z,Z))
  G = -(mu:*Z)'X
  Shat = ((y-mu):*Z)'((y-mu):*Z)*rows(X)/(rows(X)-cols(X))
  Vb = luinv(G'W*G)*G'W*Shat*W*G*luinv(G'W*G)
  st_matrix("b",b)
  st_matrix("Vb",Vb)




B) Then I have calculated the probability that the binary process variable equals one.



******

predict pred
gen prnonzero=1- normal(pred)

*****



C) I would now like to use this probability to modify the conditional mean in the second part (negative binomial model).  However, despite my best efforts, I have not been able to program that the conditional mean must be "mu = (prnonzero)*Exp(Xb)" instead of  " mu = exp(Xb)".  For instance, I have tried:


****Second-part****

  local y docvis
local xlist private medicaid age age2 educyr actlim totchr cons
local zlist income ssiratio medicaid age age2 educyr actlim totchr cons
local pr prnonzero

mata void pgmm(todo, b, y, X, Z, Qb, g, H)
  {
    Xb = X*b'

*** Here I would like to modify mu so that "mu = (prnonzero)*Exp(Xb)"***

mu =(exp(Xb))*P

*******

    h = Z'(y-mu)
    W = cholinv(cross(Z,Z))
    Qb = h'W*h
    if (todo == 0) return
    G = -(mu:*Z)'X
    g = (G'W*h)'
    if (todo == 1) return
    H = G'W*G
    _makesymmetric(H)
   }
  st_view(y=., ., "`y'")
  st_view(X=., ., tokens("`xlist'"))
  st_view(Z=., ., tokens("`zlist'"))
  st_view(P=., ., "`pr'")
  S = optimize_init()
  optimize_init_which(S,"min")
  optimize_init_evaluator(S, &pgmm())
  optimize_init_evaluatortype(S, "d2")
  optimize_init_argument(S, 1, y)
  optimize_init_argument(S, 2, X)
  optimize_init_argument(S, 3, Z)
  optimize_init_params(S, J(1,cols(X),0))
  optimize_init_technique(S,"nr")
  b = optimize(S)
  // Compute robust estimate of VCE
  Xb = X*b'

*************
  mu =(exp(Xb))*P
***************
  h = Z'(y-mu)
  W = cholinv(cross(Z,Z))
  G = -(mu:*Z)'X
  Shat = ((y-mu):*Z)'((y-mu):*Z)*rows(X)/(rows(X)-cols(X))
  Vb = luinv(G'W*G)*G'W*Shat*W*G*luinv(G'W*G)
  st_matrix("b",b)
  st_matrix("Vb",Vb)



And I get a conformability error message.


2) Would a control function approach be appropriate to test for exogeneity within a ZINB model? My original idea was to include the residuals of a first stage regression in both parts of the ZINB model and test for joint significance of their coefficients.

3) Would the use of IV estimation methods for the linear regression model be adequate to test for the validity of overindentifying instruments?

Yours sincerely,

Rodolphe Desbordes











*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index