Announcement

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

  • help with the logitfe command

    Hello, I am trying to use the -logitfe- command to run the model shown below. I have dataset with 3 periods of data from a survey, and I want to run a logit fixed effects regression using one lagged time period of the dental_Wave outcome variable, but I get the error that can be seen below. I wonder if my data is not structured properly; I have included a -dataex- of the data, the dataset was originally in wide format, so I transformed it to long data format, it's also possible that the variables I selected don't have enough variation between time periods and produce the problems below. Any guidance would be greatly appreciated, thank you.



    Code:
    
    .
    . logitfe dental_Wave ///
    >     L1.dental_Wave ///  
    >     c.depressive_symptoms_Wave3  c.depressive_symptoms_Wave4 c.depressive_symptoms_Wave5 /// <- 1 to 4 lags of depression
    >     c.age_Wave3 c.age_Wave4 c.age_Wave5 i.smoked_marijuana_alt_Wave3 i.smoked_cigarettes_Wave4 ////
    >         i.smoked_cigarettes_Wave5 c.smoked_cigarettes_Wave3 c.smoked_cigarettes_Wave4 c.smoked_cigarettes_Wave5 ///
    >     i.alcohol_Wave3 i.alcohol_Wave4 i.alcohol_Wave5 i.education_Wave3 i.education_Wave4 i.education_Wave5, ///
    >     analytical ieffects(yes) teffects(yes)
    
    Computing uncorrected fixed effects estimator
    
    note: 11.smoked_cigarettes_Wave5 != 0 predicts failure perfectly;
          11.smoked_cigarettes_Wave5 omitted and 2 obs not used.
    
    note: 19.smoked_cigarettes_Wave5 != 0 predicts failure perfectly;
          19.smoked_cigarettes_Wave5 omitted and 4 obs not used.
    
    note: smoked_cigarettes_Wave4 omitted because of collinearity.
    note: smoked_cigarettes_Wave5 omitted because of collinearity.
    note: multiple positive outcomes within groups encountered
    note: multiple positive outcomes within time periods encountered
    note: 5725 groups (11393 obs) dropped because of all positive or
          all zero outcomes
    note: depressive_symptoms_Wave3 omitted because of no within-group variance
    note: depressive_symptoms_Wave4 omitted because of no within-group variance
    note: depressive_symptoms_Wave5 omitted because of no within-group variance
    note: age_Wave3 omitted because of no within-group variance
    note: age_Wave4 omitted because of no within-group variance
    note: age_Wave5 omitted because of no within-group variance
    note: smoked_cigarettes_Wave3 omitted because of no within-group variance
    Iteration 0:  f(p) = -3941.7763  
    Iteration 1:  f(p) = -2425.3123  
    Iteration 2:  f(p) = -2281.2968  
    Iteration 3:  f(p) = -2258.8606  
    Iteration 4:  f(p) = -2254.2237  
    Iteration 5:  f(p) = -2253.2433  
    Iteration 6:  f(p) =  -2253.023  
    Iteration 7:  f(p) = -2252.9684  
    Iteration 8:  f(p) = -2252.9575  
    Iteration 9:  f(p) = -2252.9551  
    Iteration 10: f(p) = -2252.9546  
    Iteration 11: f(p) = -2252.9545  
    Iteration 12: f(p) = -2252.9544  
    
    Computing analytical correction
    initial values not feasible
    r(1400);


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input long aid byte year float dental_Wave
    1 3 1
    1 4 1
    1 5 1
    2 3 0
    2 4 0
    2 5 0
    3 3 0
    3 4 0
    3 5 1
    4 3 0
    4 4 0
    4 5 0
    5 3 1
    5 4 0
    5 5 0
    6 3 0
    6 4 0
    6 5 1
    7 3 1
    7 4 1
    7 5 0
    8 3 0
    8 4 1
    8 5 1
    9 3 0
    9 4 1
    9 5 1
    10 3 0
    10 4 0
    10 5 1
    11 3 1
    11 4 0
    11 5 0
    12 3 1
    12 4 0
    12 5 1
    13 3 1
    13 4 0
    13 5 0
    14 3 1
    14 4 0
    14 5 0
    15 3 1
    15 4 1
    15 5 1
    16 3 1
    16 4 0
    16 5 1
    17 3 0
    17 4 0
    17 5 0
    18 3 1
    18 4 0
    18 5 1
    19 3 0
    19 4 0
    19 5 1
    20 3 1
    20 4 1
    20 5 1
    21 3 0
    21 4 0
    21 5 1
    22 3 1
    22 4 1
    22 5 1
    23 3 1
    23 4 1
    23 5 0
    24 3 0
    24 4 0
    24 5 1
    25 3 1
    25 4 1
    25 5 0
    26 3 1
    26 4 0
    26 5 0
    27 3 0
    27 4 0
    27 5 0
    28 3 1
    28 4 0
    28 5 0
    29 3 0
    29 4 1
    29 5 1
    30 3 1
    30 4 1
    30 5 1
    31 3 1
    31 4 1
    31 5 0
    32 3 1
    32 4 0
    32 5 0
    33 3 1
    33 4 1
    33 5 0
    34 3 0
    end
    label values aid id
    label def id 1 "10506342", modify
    label def id 2 "11316958", modify
    label def id 3 "11574211", modify
    label def id 4 "12504295", modify
    label def id 5 "12572562", modify
    label def id 6 "12578037", modify
    label def id 7 "13676851", modify
    label def id 8 "13715895", modify
    label def id 9 "14316051", modify
    label def id 10 "14574194", modify
    label def id 11 "14590357", modify
    label def id 12 "14676257", modify
    label def id 13 "14714942", modify
    label def id 14 "15574600", modify
    label def id 15 "15578543", modify
    label def id 16 "15676328", modify
    label def id 17 "17254985", modify
    label def id 18 "17316657", modify
    label def id 19 "17508726", modify
    label def id 20 "17608972", modify
    label def id 21 "17676352", modify
    label def id 22 "18614276", modify
    label def id 23 "18676822", modify
    label def id 24 "18710296", modify
    label def id 25 "19508388", modify
    label def id 26 "19606222", modify
    label def id 27 "19614572", modify
    label def id 28 "20540757", modify
    label def id 29 "20574505", modify
    label def id 30 "20574622", modify
    label def id 31 "20676929", modify
    label def id 32 "22574932", modify
    label def id 33 "22712340", modify
    label def id 34 "24614574", modify
    label values dental_Wave dental
    label def dental 0 "0.More than 1 year", modify
    label def dental 1 "1.Last Year", modify
    Last edited by Luis Mijares Castaneda; 01 Sep 2025, 19:00.

  • #2
    Your dataex only contains 3 variables but you use many more in your command. I suspect that not all variables are actually in long format. Make sure that all controls are also in long. Variable names like
    Code:
    i.smoked_cigarettes_Wave5 c.smoked_cigarettes_Wave3 c.smoked_cigarettes_Wave4
    Give me the impression that these are still in wide. This will not work.
    Best wishes

    Stata 18.0 MP | ORCID | Google Scholar

    Comment


    • #3
      Felix Bittmann

      I changed the data to make all the variables in long format, but I still get problems when using the -logitfe- model, I want to include lags of the Dental_Wave outcome variable


      Code:
      
      . 
      . logitfe dental_Wave ///
      >     L1.dental_Wave ///  <- 1 to 4 lags of outcome
      >     c.depressive_symptoms_Wave c.age_Wave i.smoked_marijuana_alt_Wave i.smoked
      > _cigarettes_Wave ///
      >     i.alcohol_Wave i.education_Wave, ///
      >     analytical ieffects(yes) teffects(yes)
      
      Computing uncorrected fixed effects estimator
      
      note: multiple positive outcomes within groups encountered
      note: multiple positive outcomes within time periods encountered
      note: 5913 groups (11625 obs) dropped because of all positive or
            all zero outcomes
      Iteration 0:  f(p) = -3957.5092  
      Iteration 1:  f(p) = -2372.2041  
      Iteration 2:  f(p) = -2222.6291  
      Iteration 3:  f(p) = -2196.7665  
      Iteration 4:  f(p) = -2191.5725  
      Iteration 5:  f(p) = -2190.3398  
      Iteration 6:  f(p) = -2189.9916  
      Iteration 7:  f(p) = -2189.9015  
      Iteration 8:  f(p) = -2189.8768  
      Iteration 9:  f(p) = -2189.8702  
      Iteration 10: f(p) = -2189.8687  
      Iteration 11: f(p) = -2189.8685  
      Iteration 12: f(p) = -2189.8685  
      
      Computing analytical correction
      initial values not feasible
      r(1400);

      Comment


      • #4
        This looks already much better. However, where exactly the problem lies is not possible to say currently. I suggest to start with a very simple model. No lags, no controls. Find something that works. Then you can add more controls and build a more complex model. This approach will help you find the issue. How many total individuals and data points are in your dataset?
        Best wishes

        Stata 18.0 MP | ORCID | Google Scholar

        Comment


        • #5
          My dataset consists of 3 time periods and Observations: 27,447. When I include the analytical correction, I get the problem of numerical overflow.

          Comment

          Working...
          X