Announcement

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

  • LCA by groups: No observations error message

    Hi everyone!

    I have done a LCA with 7 variables and 5 classes.

    Code:
    gsem (a1107_e a1113_b a1113_e a1113_f a1113_g_new a1113_h a1114_a <-), ologit lclass(C 5)
    As my survey data consists of several countries, I would now like to see whether the coefficients vary over these different countries. However, I keep receiving an error message stating that there are no observations.

    Code:
     gsem (a1107_e a1113_b a1113_e a1113_f a1113_g_new a1113_h a1114_a <-), ologit lclass(C 5) group(acountry) ginvariant(coef)
    no observations
    r(2000);
    Could you explain to me what I did wrong, and how I could solve this problem? If I use the same code for gender instead of country everything works smoothly and I receive the latent classes per gender; no error message appears.
    I have no missing values in my country-variable.

    Thank you very much for every piece of advice!



  • #2
    Perhaps country is a string variable?

    Comment


    • #3
      Thank you, Clyde
      However, my country variable is numeric and not string.


      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input byte(acountry asex a1113_h)
      11 2  1
      11 2  2
      11 1  4
      11 1  3
      11 2  2
      11 1  2
      11 2  1
      11 2  2
      Last edited by Michelle Reiter; 07 Jun 2022, 00:17.

      Comment


      • #4
        Well, here's another guess. Perhaps for some level(s) of variable acountry, the estimation sample is empty due to missing values on other variables. Remember that if any of the model variables has a missing value, that entire observation is excluded from the estimation sample. So scattered missing values in the data can easily deplete an estimation sample. Try the following:
        Code:
        egen mcount = rowmiss(a1107_e a1113_b a1113_e a1113_f a1113_g_new a1113_h a1114_a)
        by acountry, sort: egen estimation_sample_size = total(mcount == 0)
        levelsof acountry if estimation_sample_size == 0
        to get a list of countries that have no usable observations.

        Comment

        Working...
        X