Announcement

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

  • lclogit (Latent class for choice modeling)- how do I test for differnces in class membership by demographic variables?

    I used the following code and I have two distinct class membership:

    lclogit choice $varse, id(respid) group(resptask) nclasses(2) nolog

    Now, let's say I want to determine if there is a difference between males and females (using the variable name 'gender'). What should be the code I use? By the end of this process, I aim to create a table that displays the proportion of each group (male vs female) under each membership class and indicates whether there is a significant difference between them

    I am VERY new to coding with Stata. I am conducting a discrete choice experiment and best worst scaling (case 1) for my research.

    Thank you for your help in advance!

    -Rotana

  • #2
    Rotana Radwan: -lclogit- generates point estimates by applying the EM algorithms, but does not generate associated standard errors. To obtain the standard errors, you can pass -lclogit- estimates to -lclogitml- as starting values. Please see the background paper for -lclogit-. [Link]

    Having said that, there's now an enhanced version, -lclogit2- and -lclogitml2-, which runs faster and offers more options. I'd like to encourage you to use this enhanced version instead. You can find more information in the background paper for -lclogit2-. [Link]

    Once you've obtained standard errors of your estimates using -lclogitml2- (or -lclogitml- for that matter), you can test the equality of coefficients across classes by applying Stata's native -test- command. For example, you can type
    Code:
    test [Class1]price = [Class2]price
    in Stata to test whether the two classes share the same coefficient on variable -price-.

    I'd like to encourage you to consult Stata's user manual entry for the native -nlcom- command if you're interested in testing between-class differences in non-linear combinations of parameters; and for the native -predictnl- command if you're interested in testing between-class differences in non-linear combinations of parameters and variables such as predicted probabilities. You can access these entries by typing -help nlcom- and -help predictnl-. You can then click the PDF link under the "Also see" tab, which provides much more detailed information than the default dialogue box that you'll see.

    Comment


    • #3
      Hi Dr. Yoo, Thank you for your reply and help. For the past two days, I've been trying to learn & implement your advise..but I've been running into an error...
      Code:
      lclogit choice $varse, id(respid) group(resptask) nclasses(2) nolog
      lclogitml, iterate(500)

      Error: choice is not a 0/1 variable which equals 1 for the chosen alternative.

      I saw another stata user having the same issue and resolved it by "In choice experiment data you must ensure that at least each choice set has an =1"

      In my BWS (Case 1) results,I am positive that participants chose best=1 and worst =0 for each choice task... (no missing values... responses were forced on qualtrics)

      Thank you for your time and input.

      Comment


      • #4
        Rotana Radwan:

        First, you can double-check whether your -group()- variable has been coded as expected by -clogit- and its community-contributed extensions (e.g., -mixlogit-, -lclogit2-). The value of your -group()- variable must be unique to each {person, choice scenario}. For example, choice scenario 1 for person 1 should have a different value from choice scenario 1 for person 2. The easiest way to get this done is to type
        Code:
        egen double taskid = group(respid resptask)
        and use -taskid- as your -group()- variable going forward, e.g., -lclogit choice $varse, id(respid) group(taskid) nclasses(2) nolog-.

        Second, you can double-check whether your choice indicator has been coded as expected by -clogit- and its community-contributed extensions (e.g., -mixlogit-, -lclogit2-). You can type
        Code:
        by respid taskid: egen double total_choice = total(choice)
        tabulate choice
        and examine whether -total_choice- add up to 1 within each block of observations identified by -taskid- as required.

        Comment


        • #5
          Hi Dr. Yoo!

          With the code you gave me, I've realized that I have 8 total choices....that's because of how the data is organized (I have 7 choice tasks in my BWS. with 4 objects each). I really appreciate your help and want to thank you for it! Thank you for creating these codes and helping us learn and understand too

          Comment


          • #6
            Rotana Radwan: Great to hear, thanks for your kind words!

            Comment


            • #7
              Hong Il Yoo Hi Dr. Yoo,

              Following up on this thread, is there a way to assess the performance of the class membership model - like checking how many membership variables are more desired? I currently use two two-level variables and a three-level variable to generate dummies for membership variables. I wanted to see if adding additional demographic variables or reducing the number of membership variables is more reasonable.

              Thank you in advance!

              Comment


              • #8
                Jiayun Shen: One simple approach is to test down your model from a general specification that includes all variables of interest, by applying usual significant tests or comparing information criteria. But in my limited experience, this simple approach is difficult to implement, not least because the general specification is often not empirically identified. You may find it useful to consider alternative methods reviewed by Bakk and Kuha (2020; https://doi.org/10.1111/bmsp.12227) and have a look at some of references therein.

                Comment

                Working...
                X