Poisson regression using Panel data requires the dependent variable ($y_{it}$) to be a non-negative count variable. I need to take the first difference of the dependent variable to deal with reverse causality of the regressors. Cameron and Trivedi's Microeconometrics using Stata outline a transformation




which, they state, can be used to eliminate the FE and as the basis for estimation of dynamic panel count models. My question is how can one actually estimate $\lambda_{it}$ (ideally in Stata) so that it can then be used to create first differences?


1 Answer 1


It seems that I need to use the gmm program evaluator to take the differencing as required in the question. I wrote the following program but it's not running and giving the error

could not calculate numerical derivatives -- flat or discontinuous region encountered

the program that I wrote is as follows

capture program drop gmm_poifd
program gmm_poifd
    version 11
    syntax varlist if, at(name) myrhs(varlist) mylhs(varlist) myidvar(varlist)
    quietly {
    tempvar mu muLag yLag
    gen double `mu' = 0 `if'
    local j = 1
    foreach var of varlist `myrhs' {
        replace `mu' = `mu' + `var'*`at'[1,`j'] `if'
        local j = `j' + 1
    replace `mu' = exp(`mu')
    gen double `muLag' = L.`mu' `if'
    gen double `yLag' = L.`mylhs' `if'  
    replace `varlist' = `muLag'/`mu' * `mylhs' - `yLag' `if'

gmm gmm_poifd, mylhs(PostMile1) myrhs(Traffic $Messages $Time $Weather) /// 
myidvar(MessageBoardID) nequations(1) parameters(Traffic $Messages $Time $Weather) ///
instruments(Traffic $Messages $Time $Weather) onestep

Can somebody please help me identify the problem and fix this answer?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.