Announcement

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

  • Finite Mixture Models in STATA 15 - postestimation code from earlier Stata versions does not work

    Dear all,

    I have worked on latent class/finite mixture models with earlier STATA Versions. One postestimation that I find convenient and want to "replicate" with STATA 15 is supposed to do the following:

    I estimate a 2-component Finite Mixture Model. After the estimation I want to have a closer look at the observations in the 2 classes/components. With Stata Versions earlier than STATA 15, I did the following:

    predict yhat1 if e(sample), eq(component1)
    predict yhat2 if e(sample), eq(component2)
    predict pria if e(sample), pri eq(component1)
    predict posa if e(sample), pos eq(component1)

    gen comp1_1 = (posa>0.5)
    replace comp1_1=2 if comp1_1==0
    tabstat yhat* pria posa, by(comp1_1) stat(mean sd n)
    tabstat var1 var2 var3 var4, by(comp1_1)
    browse var1 var 2 var3 var4 if comp1_1==1


    Unfortunately, this does not work with STATA15, as there has been some changes with the "predict" command. The error message is: "option pri not allowed". I have searched the Stata Finite Mixture Models Reference Manual Version 15 but could not find anything on this.

    Could anyone help me here? My aim is to generate the dummy variable "comp1_1" which indicates to which latent class the model assigns the respective Observation. With this I can then have a deeper look into the ex ante-unobserved components. However, as the "comp1_1 variable crucially depends on pria/posa above and this command does not work, i am currently stuck and do not know how to generate this indicator with the new fmm command in STATA15.

    Thanks so much in advance!

    Cheers,
    John

  • #2
    John should use predict ..., classpr to get predicted latent class prior probabilities.

    Code:
    webuse womenwk, clear
    fmm 2: regress wage educ age married
    predict pr*, classpr
    I suspect John has both the official fmm and the user-written fmm installed on his machine, and the official fmm command takes precedence. To verify this, John can type which fmm, all and should see something like

    Code:
    . which fmm, all
    
    C:\Program Files (x86)\Stata15\ado\base\f\fmm.ado
    *! version 1.0.12  04aug2017
    
    c:\ado\plus\f\fmm.ado
    *! version 2.1.0 12feb2012
    *! author: Partha Deb
    To push the user-written fmm to the top of the search path, John can type

    Code:
    . adopath ++ PLUS
    . discard
    and the user-written fmm command should work.

    To revert back to the official ado directory being at the top of the search path, John can type

    Code:
    . adopath - PLUS
    . adopath + PLUS
    . discard

    Comment


    • #3
      John,

      Rafal has been incredibly neutral in suggesting a way to give my user-written fmm precedence over the official fmm in Stata 15. I have been using official fmm and would argue that it is better than my package in almost every respect. Unless you have a very specific reason for choosing package fmm, I recommend switching to official Stata fmm. The syntax for fmm is somewhat different so it takes a bit of getting used to, and post-estimation commands are different too. But it's well worth learning.

      Best.

      Partha

      Comment

      Working...
      X