Skip to content

add GMMPoisson (IVPoisson) #1742

Open
Open

Description

@josef-pkt

Stata has ivpoisson which has both the additive and multiplicative error model.
Besides GMM it uses a second method.

GMMPoisson is essentially finished, but it's in the test suite as a test case for GMM, and I have the notebook as usage example for GMM.
I don't remember if it has the full extra results. Unit tests are against generic GMM in Stata not against ivpoisson.

move it to discrete_models.

Stata also has ivprobit, which could follow the same pattern.
Stata doesn't have ivlogit, which, IIRC, would also be easy but doesn't have additive IV structure. I guess it would need to subclass GMM instead of IVGMM.

As bonus, with instruments=exog (no endog in explanatory variables), we would have sandwich robust covariances.

Activity

  1. added this to the 0.14 milestone on Sep 4, 2021
  2. josef-pkt commented on Nov 10, 2021

    @josef-pkt
    MemberAuthor

    gmm poisson unit tests use docvis data of cameron trivedi count book (racd)

    this looks like the do file that I used to store the gmm results (to_py_poisson_gmm.do)

    insheet using racd10data_with_transformed_.csv, delimiter(",")
    
    global XLISTEXOG medicaid aget aget2 educyr actlim totchr
    global XLISTEXOG2 aget aget2 educyr actlim totchr
    *gmm ( docvis - exp({xb:private medicaid $XLISTEXOG2}+{b0})), instruments(incomet ssiratio $XLISTEXOG2) onestep vce(robust)
    *gmm ( docvis - exp({xb:private medicaid $XLISTEXOG2}+{b0})), instruments(incomet ssiratio $XLISTEXOG2) twostep vce(robust)
    
    
    *gmm ( (docvis / exp({xb:private $XLISTEXOG}+{b0})) - 1), instruments(income ssiratio $XLISTEXOG) onestep vce(robust)
    * Multiplicative heterogeneity - two step GMM
    *gmm ( (docvis / exp({xb:private $XLISTEXOG}+{b0})) - 1), instruments(income ssiratio $XLISTEXOG) twostep vce(robust) center
    *gmm ( (docvis / exp({xb:private $XLISTEXOG}+{b0})) - 1), instruments(income ssiratio $XLISTEXOG) twostep wmatrix(robust) vce(unadjusted) center
    gmm ( (docvis / exp({xb:private $XLISTEXOG}+{b0})) - 1), instruments(income ssiratio $XLISTEXOG) twostep wmatrix(robust) center
    
    capture drop cov* Sigma params_table*
    
    matrix cov = e(V)
    svmat cov, names(cov)
    matrix Sigma = e(Sigma)
    svmat Sigma, names(Sigma)
    ereturn display
    matrix params_table = r(table)'
    svmat params_table, names(params_table)
    
    estmat2nparray params_table cov, saving("...\results_gmm_poisson.py") format("%16.0g") append /*replace */
    

    I had transformed some variables from the original data set because large values caused problems in optimization (with exp mean function)

    gen aget = (age - 65) / 5
    gen aget2 = aget^2
    gen incomet = income / 10
    
    label variable aget "= (age - 65) / 5"
    label variable aget2 "= aget^2"
    label variable incomet "income / 10"
    save "...\racd10data_with_transformed.dta"
    
    global XLISTEXOG medicaid aget aget2 educyr actlim totchr
    global XLISTEXOG2 aget aget2 educyr actlim totchr
    
  3. josef-pkt commented on Nov 10, 2021

    @josef-pkt
    MemberAuthor

    (I deleted comments that I made by mistake here instead of in 7870.)

  4. josef-pkt commented on Nov 27, 2021

    @josef-pkt
    MemberAuthor
  5. josef-pkt commented on Oct 8, 2025

    @josef-pkt
    MemberAuthor

    I reference that I opened by chance (correlation and poisson in title)

    Boes, Stefan. 2010. “Count Data Models with Correlated Unobserved Heterogeneity.” Scandinavian Journal of Statistics 37 (3): 382–402. https://doi.org/10.1111/j.1467-9469.2010.00689.x.

    uses GMM and (superficially) looks similar to multiplicative GMMPoisson

    (I added articles several times to Zotero since 2012)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions