Announcement

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

  • Multiple poisson regressions with linked coefficient constraint

    I have 3 variables for which I need to run poisson regressions. The are called el, dc and tot. The independent variables are called year and post and I need the coefficients on year from el+dc to equal tot.. Although in my data el+dc=tot, in general the coefficients will not fit my constraint when using poisson because ln(A)+ln(B)<>ln(A+B).

    In pseudocode summary:

    Code:
    poisson el = {a1} + {b1}*year + {c1}*post
    poisson dc = {a2} + {b2}*year + {c2}*post
    poisson tot = {a3} + {b3}*year + {c3}*post
    constraint {b1}+{b2}={b3}
    Can anyone advise how this can be run in Stata (I'm using v15.1) please?


  • #2
    If tot = el + dc then why estimate a separate model for tot? The mean of tot is the sum of the means for the other two. Modeling the mean of tot as you are doing is a misspecification. All information is in the models for el and dc.

    Comment


    • #3
      Code:
      clear
      set seed 12345
      set obs 1000
      
      * X VARS
      gen x1 = rnormal(0,1)
      gen x2 = runiform(0,1)
      
      * LATENT
      gen lambda1 = exp(1 + 0.5*x1  - 0.3*x2)
      gen lambda2 = exp(1 + 0.25*x1 - 0.4*x2)
      
      * POISSON Y
      gen y1 = rpoisson(lambda1)
      gen y2 = rpoisson(lambda2)
      g tot = y1 + y2
      
      
      * ESTIMATE
      program dotable
      quietly {
          eststo e1: poisson y1 x1 x2
          local beta1 = _b[x1]
          margins, dydx(x1) post
          local ame1 = e(b)[1,1]
          eststo e2: poisson y2 x1 x2
          local beta2 = _b[x1]
          margins, dydx(x1) post
          local ame2 = e(b)[1,1]
          eststo e3: poisson tot x1 x2
          local beta3 = _b[x1]
          margins, dydx(x1) post
          local ame3 = e(b)[1,1]
      }
      esttab 
      di "COEFFICIENTS"
      di "beta Model 1 = " _col(20) `beta1'
      di "beta Model 2 = " _col(20) `beta2'
      di "SUM = " _col(20) `beta1' + `beta2'
      di "MEAN =" _col(20) (`beta1' + `beta2')/2
      di "beta Model 3 = " _col(20) `beta3'
      di ""
      di "MARGINAL EFFECTS"
      di "AME Model 1 = " _col(20) `ame1'
      di "AME Model 2 = " _col(20) `ame2'
      di "SUM = " _col(20) `ame1' + `ame2'
      di "MEAN = " _col(20) (`ame1' + `ame2')/2
      di "AME Model 3 = " _col(20) `ame3'
      end
      dotable

      Comment

      Working...
      X