Announcement

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

  • finite mixture model post estimation with margins plot

    Hi Statalist.

    I'm utilising the new fmm (finite mixture model) system to do some non-linear modeling of government accountability on human development.

    my estimation equation looks approximately like this:

    Code:
    fmm 2: regress y c.x1##c.x1##c.x1 c.x2##c.x2##c.x2 c.x3##c.x3##c.x3 z1 z2 z3 z4 i.country i.year
    I want to visualise the marginal effect of x1, x2 and x3 in three different plots. I also estimate a normal regression (no finite mixture model) with the same equation and utilise this command to get the plots I need:

    Code:
    margins, at(x1=(-2.2(0.2)2.3)) atmeans
    marginsplot
    margins, at(x2=(-2.2(0.2)2.3)) atmeans
    marginsplot
    margins, at(x3=(-2.2(0.2)2.3)) atmeans
    marginsplot
    The documentation for the fmm command tells me to use the "predict(eta)" option like this, for my finite mixture model
    Code:
    margins, at(id1=(-2.2(0.2)2.3)) predict(eta)
    This seems incredibly computationally intensive, and I don't know why. It also seems impossible to get estimates for anything but the first class.
    I feel like there should be a "class()" option to the margins commands

    Does anyone know how to obtain predictive margins for both classes?

    Best regards, and thanks
    Adam Hede

  • #2
    There is a class option; admittedly it is a bit difficult to decipher from the help menu. -margins- after -fmm- is computationally intensive, perhaps unreasonably so for simple -fmm- specifications but it is the cost associated with such a general prefix. In any case, the following code should help you get what you want.

    Code:
    clear all
    set more off
    
    sysuse auto
    regress price c.mpg##c.weight
    margins, at(mpg=(14(2)40)) atmeans
    marginsplot
    
    fmm 2: regress price c.mpg##c.weight
    
    margins, predict(mu class(1)) at(mpg=(14(2)40)) atmeans
    marginsplot, name(one)
    
    margins, predict(mu class(2)) at(mpg=(14(2)40)) atmeans
    marginsplot, name(two)
    
    graph combine one two, ycommon xsize(10)
    Best.

    Partha

    Comment


    • #3
      Thank you so much Partha!

      I had read over the documentation so many times, and tried the class() option, but never thought to put it inside predict! It seems to work now. Computation time is annoying, but I can manage.

      Comment

      Working...
      X