Announcement

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

  • mepoisson marginsplot: problems with marginsplot scale even after changing exposure() in model specification

    Hi, I'm running a mixed poisson model using mepoisson.
    I'm modeling events (yrtotal) per 1000 people, and I want to get the marginsplot of the interaction.
    My code runs without issues but the plot is the same when I use nt as the exposure or nt1000.
    The correct model specification is with nt1000 as my outcome is rate per 1000 people.
    Anyone knows why this is happening or how to go about this?
    thank you

    This is my code:
    Code:
    * Create exposure variable
    * total N per year
    bys measurment_yr: gen nt = _N
    * divide by 1000 to get the correct offset
    gen nt1000 = nt/1000
    
    * Crude model
    mepoisson yrtotal i.population##c.measurement_yr, ///
    exposure(nt1000) || new_id:, irr
    * Estimate marginal effects for the interaction
    margins population, at(measurement_yr = (0(1)2))
    * Plot marginal effects 
    marginsplot, plotopts(msize(*0.65)) ///
    ytitle("Visits per 1000 clients") ///
    title("Crude model") ///
    xtitle("") ///
    legend(rows(1) cols(2) size(small)) ///
    name(EDU_AE_crude_`lv'100, replace)

  • #2
    Including an exposure variable in mepoisson or poisson just results in the logarithm of this variable being included In the RHS with the constraint that its coefficient equals 1. So dividing this variable by 1000 is the same as taking away a constant ln(1000) from the logarithm, from the properties of logarithms. The only effect is that the constant term in the estimation changes. Note that:

    $$ln \left(\frac{x}{y} \right)= ln(x)- ln(y) \Rightarrow ln \left(\frac{x}{1000}\right) = ln(x)- ln(1000).$$

    In your case, it appears all you want to do is to rescale the y-axis of the marginsplot. You can do this directly on the plot, or just specify this within the -expression()- option of margins.

    Code:
    margins population, at(measurement_yr = (0(1)2)) expression(predict()*0.001)
    Last edited by Andrew Musau; 18 Jul 2023, 16:25.

    Comment

    Working...
    X