Announcement

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

  • Latent Class Analysis: profile plot by latent classes

    Hi Statalist,


    I have encountered a STATA issue when I was trying profile plot my dataset after I did the LCA (latent class analysis).

    Basically, I was following a web post by StataCorp: see https://www.stata.com/new-in-stata/latent-class-analysis/

    Everything works perfect except the step that "visually compare the probabilities of participating in these activities across classes." (please see the attached LCA picture from the website).

    I have very similar dataset and also would such an visual output by the 3 latent classes.

    The codes I used were:

    Code:
    margins 
    marginsplot
    For -margins-, there was an error saying that "Warning: prediction constant over observations."
    For -marginsplot-, I could only get a graph for all classes (y-axis is "mu").
    I wonder if anyone has some thought about this.

    Thanks in advance

    Attached Files
    Explore the new features of our latest release.

  • #2
    Yingyi,

    Marcos Almeida documented how to do this in marginsplot an earlier post. I personally went with -coefplot- (available on SSC, by Ben Jann), as I know how to control the syntax better, but it is a rather clunky process.

    I would love to see Stata document the marginsplot process better on its blog.

    While searching for Marcos' post, I noticed that Paul Lambe asked a similar question earlier. Paul, if that post didn't resolve your question, I hope this does.
    Be aware that it can be very hard to answer a question without sample data. You can use the dataex command for this. Type help dataex at the command line.

    When presenting code or results, please use the code delimiters format them. Use the # button on the formatting toolbar, between the " (double quote) and <> buttons.

    Comment


    • #3
      Thanks so much Weiwen!

      Comment


      • #4
        Hi Weiwen and all,
        I am still unable to create the same quality of combined bar graphs as advertised on the web post by StataCorp: see https://www.stata.com/new-in-stata/latent-class-analysis/ Anyone able to advise? Perhaps, as Weiwen suggested, Stata Corporation should document the marginsplot better on its blog i.e. give us the syntax. I for one have upgraded to Stata 15 specifically because LCA has been made so much easier in Stata15.
        BW
        Paul

        My syntax:-
        gsem ( lev3 stateschool lowpol highimd <-), logit lclass(C 3)startvalues(randomid, draws(30)seed(123321))intpoints(5)iter(1000)
        estat lcprob
        estat lcmean, post
        margins,dydx(*)noesample predict(outcome (1)) predict(outcome (2)) predict(outcome (3))
        marginsplot, by(_outcome) xtitle("not title") recast(bar)

        Comment


        • #5
          I don't know if your question still holds but the code is on these slides: https://www.stata.com/meeting/uk18/s..._MacDonald.pdf (slides 34-35)

          Comment

          Working...
          X