Announcement

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

  • Problem estimating latent class models

    Hello. I am having trouble estimating simple latent class models, and for my question I am using the simplest model I can.

    First, note that I have a variable called Dgiveupbinary that is indeed a categorical variable. I am sure of this because this is its tabulation

    . tabulate Dgiveupbinary

    Dgiveupbina |
    ry | Freq. Percent Cum.
    ------------+-----------------------------------
    0 | 7,809 71.37 71.37
    1 | 3,132 28.63 100.00
    ------------+-----------------------------------
    Total | 10,941 100.00

    Dgiveupbinary only takes zero or one values.


    When I try to run a simple two class latent class model using the following command

    . gsem (Dgiveupbinary <- ), logit lclass(C 2)

    I get the following error

    "
    . gsem (Dgiveupbinary <- ), logit lclass(C 2)
    option lclass() not allowed;
    option lclass() is not allowed with models specified with continuous latent variables
    r(198);
    "

    I don't understand why it believes the variable is not categorical when it is only zeros and ones. I've done some reading and there doesn't seem to be any way that Stata officially labels a variable as continuous or categorical.

    Thoughts? Any help is greatly appreciated.

    Bailey Norwood




  • #2
    Found my answer. For some reason it doesn't like the fact that 'Dgiveupbinary' begins with a capital letter. If I change it to 'dgiveupbinary' it will estimate.

    Comment


    • #3
      Hi Bailey,

      I think I remember reading in the SEM manual that variables beginning with capitals are treated as latent variables (or vice versa).

      Comment


      • #4
        As Leonardo said, by default, -sem- treats any variable starting with a capital letter as a latent variable, and it will get confused if it refers to an actual variable. In this particular case, it thinks that you are trying to fit some model for the mean of -Dgiveupbinary-, which it thinks is a latent variable, and because you didn't tell it otherwise, -sem- thinks this is a continuous latent variable. (the error message means that in this version, Stata can't fit models with both categorical (i.e. latent classes) and continuous (i.e. most other types of latent variables) together).

        You could have used options to say that variables with caps are not latent variables. If you do this, you have to exhaustively specify which varialbes are latent.

        Code:
        gsem (Dgiveupbinary <- ), logit lclass(C 2) nocapslatent latent(C)
        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

        Working...
        X