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

  • latent class model with predicted probabilities?

    I have a question that I can't find the answer to. I have a latent class model with covariates, essentially a "1-step" model that approximates a multinomial logistic regression with the latent classes as dependent variable categories. So far so good.

    gsem (inputvar1 inputvar2 inputvar3 inputvar4 inputvar5 <- ) ///
    (C <- income age male white, logit) ///
    [pweight=weightvar], logit startvalues(randomid, draws(8) seed(54321)) em(iter(5)) lclass(C 4)
    What I would like to be able to do is then use post estimation commands to generate predicted probabilities for some specific categories of variables. If I was doing a multinomial logistic regression, I would do this with Long and Freese's mtable command as below, or simply with margins. In the present case I would like to be able to do something similar for predicted probabilities of class membership as in the model.
    mtable, at (male(1 0) white(1 0)) atmeans ci
    Is it possible to do something like this for the model here? If so, does anyone know how? I can't figure it out. (The margins command does run after the model, but returns probabilities for each of the input variables, not for the latent classes).

  • #2
    Sorry, I should have added: Stata/IC 15.1 on mac. So (as above) latent class analysis within gsem


    • #3
      Joseph can compute marginal predictions for the latent class
      probabilities with the predict() option of margins.

      The list of suboptions allowed within option predict() of
      margins for gsem estimation results is documented

      predict after gsem has an option named classpr for
      predicting class probabilities. Use option class() to specify
      which latent class to compute the probabilities.

      Given Joseph's example above, the call to margins would be
      something like

      margins, predict(classpr class(1))     ///
               predict(classpr class(2))     ///
               predict(classpr class(3))     ///
               predict(classpr class(4))     ///
               at(male=(1 0) white=(1 0))    ///
      If Joseph changed the model specification to use factor variables
      notation on the variables male and white, i.e.
      i.male and i.white, then the call to margins could
      be changed to

      margins male#white,                    ///
               predict(classpr class(1))     ///
               predict(classpr class(2))     /// 
               predict(classpr class(3))     ///
               predict(classpr class(4))     ///
      and the output might look a little better.

      I've also attached an example using simulated data.
      Attached Files


      • #4
        Thank you for this! I tried a few predict commands but was missing the way to do it.