Announcement

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

  • Fitting a latent class model using SEM path diagram

    Hi,
    I cam across an example of a latent class model presented in the Stata conference 2021 using -gsem-. I understand what is being done but can't find a way to fit the model using Stata's -sem-path diagram (model building and estimation). Any suggestion on how to fit such model using the path diagram is much appreciated. The codes for the model and the data example given below:

    Code:
    #delimit ;
    gsem (1.C: depress <- r@0 depbase@c1 risk@c2)
      (2.C: depress <- r depbase@c1 risk@c2)  
      (1.C: comp <- _cons@-15, logit)  
      (2.C: comp <- _cons@15, logit)
      (C <- age educ motivate econ assert single nonwhite),
      lclass(C 2)
     ;
     #delimit cr
    The sample data is below:

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(depress depbase risk age educ motivate econ assert single nonwhite r c comp)
    -1.28 2.73 1.67 28.75 13   4 3.33  4.5 1 0 0 1 .
     -.27 2.18 1.55 28.27 13   5    4 3.25 1 0 0 1 .
     -.19 2.64  1.6 26.33 14 6.5 1.67  2.5 1 0 0 1 .
     -.82 2.18  1.5 39.09 16 6.5    5    5 1 1 0 1 .
      .36 2.64 2.01 37.92 11 5.5    5 2.75 1 1 0 1 .
    -1.18 2.45 1.89 28.81 12   4 4.33    2 1 0 0 1 .
      .45 2.91 2.15  38.7 12 5.5    4 1.75 1 0 0 1 .
        0 2.82 1.88 39.27 12   4 2.33 1.75 0 0 0 1 .
    -1.45 2.45  1.7 29.92 17 4.5 3.67    3 1 0 0 1 .
     -.73 2.55 1.61 39.78 16 5.5 2.33 2.75 0 0 0 1 .
     -.81 2.45 1.62 33.97 13 4.5 3.67 3.75 1 0 0 1 .
     -.64 2.73 1.97 42.13 16 6.5    5 3.75 1 0 0 1 .
    -1.37 2.82 1.84 32.27 14 4.5    4 4.25 0 0 0 1 .
    -1.18 2.18  1.7  31.7 14 4.5    5    3 1 0 0 1 .
    -1.09 2.27 1.52  32.8 13 4.5 4.33  4.5 0 1 0 1 .
    -1.37 2.64 1.73 34.21 15 5.5 2.67  2.5 1 1 0 1 .
      .72 2.64 1.66 22.04 12   5 2.33 2.75 1 1 0 1 .
     -.27 1.91  1.5 25.04 13 5.5 4.33  2.5 0 0 0 1 .
     -.54  2.9 2.04 37.85 14   6 4.33 3.25 1 1 1 1 1
    -1.27 2.82    2 35.33 13 5.5 4.67  3.5 0 1 1 0 0
      .27 2.64 1.82 43.13 12 4.5 4.67 4.25 1 0 1 0 0
    -1.27 2.45 1.85  26.3 13 5.5 4.67 2.75 1 0 1 0 0
      .09 2.73 1.74 42.05 12 6.5 3.67 4.25 1 0 1 1 1
      .37 2.36 1.56 18.79 12   6    3    3 1 0 1 0 0
     -.36 2.27 1.49 39.99 13 6.5 3.33  3.5 1 0 1 1 1
    -1.37 2.55 1.67 34.89 13 3.5    4 4.25 1 0 1 0 0
      .54 2.73  1.9 35.57 12   5 4.67    4 1 0 1 1 1
     1.45    2 1.44 18.47 11   5 3.67 2.75 1 0 1 0 0
       -1 2.55 1.71 38.67 12 5.5 3.33    3 0 0 1 0 0
     -.82 2.82 1.93 37.99 13   5 3.33  2.5 1 0 1 1 1
    -1.16 2.45  1.8 71.38 10 5.5 4.67 3.25 0 0 1 1 1
     -.18 2.45 1.85 47.61 10   5 4.67 2.75 0 0 1 1 1
      .82 2.45 1.62 39.88 13   5 3.67 3.75 1 0 1 1 1
      .46 2.18 1.47 50.96  9   5    3 2.75 1 0 1 1 1
     -.72 2.27 1.61 31.05 10 4.5 3.67 2.75 1 0 1 1 1
     1.27 2.55 1.82 20.58 12 6.5 4.33 3.25 0 0 1 0 0
     -.46  2.1 1.58 24.98 14   5    5 3.75 1 1 1 0 0
    -1.64 2.82  1.9 28.15 16 5.5 3.67 3.25 1 0 1 0 0
      .18 2.09 1.48 26.96 12   5 4.33 3.75 1 0 1 0 0
     -.91 2.27 1.45 33.42 17 5.5    3  3.5 1 0 1 1 1
      .46 2.45 1.39 27.91 16 4.5 2.67 4.75 0 0 1 0 0
     -.73 2.55 1.63  31.6 16 4.5 3.67 4.25 1 0 1 1 1
      -.5  2.2 1.57 57.77 13   5 4.67    4 1 0 1 1 1
    -1.82    3  2.1 51.13 16   6 4.33 3.25 1 0 1 1 1
     -.55 2.55 1.82 39.87 12   5    4 2.75 0 0 1 0 0
     -.55 2.73 1.71 48.98 17   4    4    5 1 0 1 0 0
       -1 2.73 1.55  21.7 13   5    2    4 0 0 1 0 0
      .18 2.55 1.86 40.59 16   4 4.67 3.25 1 1 1 1 1
    -1.09 2.45 1.51 27.93 14 4.5    3    4 1 0 1 0 0
    -1.37 2.55 1.84 48.29 13   6 4.33    3 1 0 1 1 1
     -.09 2.09 1.67 44.82 17   6    4  1.5 1 0 1 1 1
    end
    Thanks.




    Roman

  • #2
    More specifically, what I am asking is how to define a 2-class solution for a latent variable using SEM path diagram? I am referring to the ( ,lclass(C 2) ) option part in the codes above

    Code:
     
     , lclass(C 2)
    Roman

    Comment


    • #3
      Originally posted by Roman Mostazir View Post
      More specifically, what I am asking is how to define a 2-class solution for a latent variable using SEM path diagram? I am referring to the ( ,lclass(C 2) ) option part in the codes above
      Sorted. We can't. P.36 -sem- manual says, "we cannot draw path diagrams in the Builder to fit latent class models. Instead, we fit
      latent class models using the command language"
      .
      Roman

      Comment

      Working...
      X