Announcement

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

  • xtsemipar errors with "no observation", but xtreg works well.

    Dear All,

    I am running a xtsemipar in Stata 17. The xtreg works well, but xtsemipar always gives me an error "no observation" back. Does xtsemipar requires strong balanced data with no gap?

    Code:
    . tsset houseid monthtime
    
    Panel variable: houseid (unbalanced)
     Time variable: monthtime, 1 to 239, but with gaps
             Delta: 1 unit
    
    . xtreg lask loss xbt i.Listtime
    
    Random-effects GLS regression                   Number of obs     =     72,908
    Group variable: houseid                         Number of groups  =     54,789
    
    R-squared:                                      Obs per group:
         Within  = 0.3118                                         min =          1
         Between = 0.1914                                         avg =        1.3
         Overall = 0.1908                                         max =          7
    
                                                    Wald chi2(240)    =   20561.80
    corr(u_i, X) = 0 (assumed)                      Prob > chi2       =     0.0000
    
    ------------------------------------------------------------------------------
            lask | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
            loss |   .1015093   .0061341    16.55   0.000     .0894866     .113532
             xbt |  -.5021619   .0190543   -26.35   0.000    -.5395076   -.4648162
                 |
        Listtime |
         200103  |  -.1275978   .4157639    -0.31   0.759      -.94248    .6872844
         200104  |  -.1969312   .4047043    -0.49   0.627    -.9901372    .5962747
    The xtreg works well, but xtsemipar never works.

    Code:
    . xi: xtsemipar lask xbt i.Listtime, nonpar(loss)
    i.Listtime        _IListtime_200102-202012(naturally coded; _IListtime_200102 omitted)
    no observations
    r(2000);

  • #2
    I have the same issue as Zhaohui. I am using xtsemipar installed from SSC. I am able to run the example code in the help file without any issues.

    When I run the following code, I get the same r(2000) error message that there are no observations:

    Code:
    xtset hhid panel
    
    Panel variable: hhid (strongly balanced)
     Time variable: panel, 2016 to 2019, but with gaps
             Delta: 1 unit
    
    xi: xtsemipar gdqs head_ed head_age count1 count2 count3 count4 count5 count6, nonpar(ln_exp_total_ame_real) 
    no observations
    r(2000);
    I ran this with both my full dataset (unbalanced panel) and with a balanced subset of the data shown in the data example below, and neither worked.

    Thanks in advance for any suggestions,
    Rachel

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input long hhid float panel double gdqs float(ln_exp_total_ame_real head_ed head_age) double(count1 count2 count3 count4 count5 count6)
      2 2016  6.25 3.4446115  0 71 0 1 0 0 2 0
      2 2019 13.25 4.4412217  0 74 1 0 0 1 2 0
      8 2016 11.25 4.5877347  3 29 1 0 0 1 1 0
      8 2019  9.25  4.982883  3 32 1 1 0 1 1 0
      9 2016  9.75  3.900762  8 48 0 2 0 4 2 0
      9 2019    16 4.6334696  8 51 1 1 0 4 2 0
     11 2016   5.5  3.413504  7 41 1 0 0 2 1 0
     11 2019     9 4.6147795  7 44 1 0 0 1 1 0
     12 2016   2.5 3.1625936  7 45 2 0 3 2 1 0
     12 2019  16.5 4.3294926  7 48 1 0 4 2 1 0
     13 2016 14.25  3.789814  6 24 0 0 0 1 1 0
     13 2019  8.75  5.876505 10 27 0 0 0 1 1 0
     14 2016     6  4.618134 11 38 0 1 1 1 1 0
     14 2019   9.5  5.401401 11 41 1 0 1 2 2 0
     15 2016     8  4.053877  6 42 0 0 1 1 1 0
     15 2019     8  4.694216  6 45 0 0 1 0 2 0
     17 2016    10  3.070196  4 53 1 3 1 1 2 0
     17 2019 15.25 4.4157305  8 56 2 3 1 1 2 0
     18 2016    10  3.804385 12 33 2 0 1 1 1 0
     18 2019    14  5.012512 12 36 0 0 2 1 0 0
     20 2016  9.75  4.332718  0 84 0 0 0 0 0 0
     20 2019     8  4.824091  0 87 0 0 0 0 0 0
     21 2016     9 4.3714933  8 71 0 0 0 0 1 1
     21 2019    19  5.031977 10 75 0 0 0 0 0 1
     23 2016     7  3.435811  7 35 1 0 0 1 1 0
     23 2019  14.5  5.833133  8 38 1 2 0 1 1 0
     25 2016  7.75 3.4447315 12 32 0 3 1 1 2 0
     25 2019  8.25  4.836698 12 35 0 2 0 2 2 0
     28 2016   8.5  2.928604  7 41 1 1 1 2 2 0
     28 2019 15.75   5.75779  8 33 1 1 1 2 1 0
     29 2016  8.25 3.9131794  0 58 0 1 0 1 1 0
     29 2019  10.5  4.058066  7 44 1 2 1 2 1 0
     32 2016   6.5  2.882545  7 44 0 3 1 1 5 0
     32 2019  13.5  5.106659  2 61 0 1 1 1 1 0
     37 2016  8.75  3.294109 10 52 1 2 1 3 2 0
     37 2019  20.5  4.845502  7 47 2 3 1 2 2 0
     41 2016 10.75 3.8724535  5 83 0 0 1 0 5 1
     41 2019   8.5    4.0261  7 43 1 1 2 1 2 0
     43 2016  11.5  5.183199 21 73 0 0 0 0 0 1
     43 2019    12 4.5817895 10 30 0 2 0 1 1 0
     45 2016   6.5 4.5979156  8 55 0 0 0 0 2 0
     45 2019  22.5  5.170694 10 55 0 2 1 3 1 0
     49 2016  12.5   3.21257  8 43 0 3 3 2 1 0
     49 2019  11.5  4.850178  4 86 0 0 0 0 4 1
     59 2016  9.25  4.071819 12 52 0 0 3 2 4 0
     59 2019  12.5  5.828377  8 58 0 0 0 0 2 0
     63 2016  6.75  3.547598 12 42 1 1 1 2 1 0
     63 2019  12.5  5.450544  8 45 1 2 3 2 2 0
     64 2016 16.75  4.060444  8 40 0 0 1 1 2 0
     64 2019 17.75  5.084167 10 51 0 1 2 3 1 0
     68 2016 20.25 4.2124496  8 58 0 0 0 1 0 0
     68 2019  11.5  5.111948  2 70 0 1 0 0 0 0
     73 2016   8.5 4.3803205  4 28 2 1 0 1 1 0
     73 2019 15.75  5.740118 23 55 0 0 2 2 5 0
     74 2016  1.75  3.724155  7 37 2 1 0 1 1 0
     74 2019  6.75 4.3725934  8 50 1 2 1 3 1 0
     77 2016 16.75 2.6934404  5 54 0 1 5 3 3 0
     77 2019   9.5  3.977259 12 36 1 1 1 1 1 0
     81 2016 14.75  6.524895  4 43 1 1 1 1 2 0
     81 2019  11.5  5.564707  8 43 0 0 0 1 3 0
     82 2016   8.5  3.768299  8 47 0 1 0 3 1 0
     82 2019     9  4.939783 10 37 1 1 1 1 1 0
     84 2016  9.25  3.929361  8 54 1 3 0 3 3 0
     84 2019     7  5.566584  8 61 0 0 0 1 0 0
     85 2016  15.5  5.028927 12 32 1 1 0 1 1 0
     85 2019    18  5.436955  4 55 0 0 1 1 1 0
     89 2016     3 3.2299054 10 56 0 3 1 4 2 0
     89 2019 20.25  5.284951  3 31 1 1 0 1 1 0
     90 2016  11.5  3.459547  8 44 0 3 0 2 1 0
     90 2019    14  4.907301  5 40 1 1 1 1 1 0
     91 2016    12  4.050189  8 80 0 0 0 0 1 1
     91 2019 14.75  5.106534  4 56 0 0 4 3 2 0
    100 2016  6.75  4.715047  8 19 0 0 0 1 1 0
    100 2019 14.25  5.364425  7 68 0 0 1 1 1 1
    101 2016     6  4.617629  8 21 1 0 0 1 1 0
    101 2019   4.5 4.4196815  4 46 0 1 1 2 2 0
    102 2016 11.25 3.5861156  8 25 1 0 0 1 1 0
    102 2019 12.75  4.936098  8 50 1 1 0 3 2 0
    106 2016  7.75  3.100066 11 55 2 1 2 2 5 0
    106 2019 11.75 4.6856527  8 57 1 2 0 2 2 0
    109 2016   4.5 4.0173492  1 58 0 0 0 1 1 0
    109 2019     9  6.352888 11 35 0 0 0 1 0 0
    111 2016 14.75   4.36237  5 88 0 0 0 1 1 1
    111 2019 16.75  5.854352  8 36 1 2 1 1 1 0
    112 2016   8.5  4.324098 12 39 1 0 1 1 1 0
    112 2019 13.75  5.102047 11 59 0 2 0 2 3 0
    114 2016  8.25  4.886748  2 50 1 1 0 0 2 0
    114 2019  7.75  5.502358 11 25 1 0 0 1 1 0
    116 2016 12.25  3.398968  7 48 0 1 0 2 2 0
    116 2019 13.75  4.996436  8 47 0 1 0 4 2 0
    125 2016 16.75 3.4168305  6 35 2 0 2 1 2 0
    125 2019   6.5  3.860702 10 43 0 3 1 2 3 0
    127 2016  9.25 3.9059744 11 52 1 0 0 3 3 0
    127 2019  12.5   5.72225  5 44 0 1 0 2 1 0
    129 2016  5.75  3.456822  4 62 2 3 2 2 2 0
    129 2019   7.5  5.175564  5 24 2 0 0 1 1 0
    135 2016  8.75 4.5290327  5 33 2 1 0 1 1 0
    135 2019   5.5  4.973907  7 26 1 0 1 1 1 0
    136 2016 11.75 4.2116714  7 51 1 2 1 1 1 0
    136 2019 12.25  6.282279  8 28 1 0 1 1 1 0
    end

    Comment


    • #3
      I guess the issue comes from the time interval. I tried your data by forcing the time variable to have no gaps. Now it works well.

      generate year=panel

      . replace year=2017 if year==2019
      (50 real changes made)
      .
      . xtset hhid year

      Panel variable: hhid (strongly balanced)
      Time variable: year, 2016 to 2017
      Delta: 1 unit
      .
      . xi: xtsemipar gdqs head_ed head_age count1 count2 count3 count4 count5 count6, nonpar(ln_exp_total_ame_real)

      Number of obs = 50
      Within R-squared = 0.5596
      Adj Within R-squared = 0.2661
      Root MSE = 5.2787
      ------------------------------------------------------------------------------
      gdqs | Coefficient Std. err. t P>|t| [95% conf. interval]
      -------------+----------------------------------------------------------------
      head_ed | -.1787681 .2124221 -0.84 0.407 -.6125919 .2550556
      head_age | .003307 .0823478 0.04 0.968 -.1648696 .1714836
      count1 | 1.316817 1.072086 1.23 0.229 -.8726749 3.506308
      count2 | .1818861 .6950869 0.26 0.795 -1.237671 1.601443
      count3 | 1.333343 .980455 1.36 0.184 -.6690135 3.335699
      count4 | .8391562 .946566 0.89 0.382 -1.093989 2.772302
      count5 | -.024191 .7691383 -0.03 0.975 -1.594981 1.546599
      count6 | 3.173713 5.13584 0.62 0.541 -7.315072 13.6625
      ------------------------------------------------------------------------------

      Comment


      • #4
        Great, yes, it works for me now. Thanks for your help!

        Comment


        • #5
          #3 diagnoses the issue correctly, but you need not define a new time variable or modify the existing one. Just xtset your data properly so that Stata recognizes that a time unit is 3 years.

          Code:
           xtset hhid panel, delta(3)
          Res.:

          Code:
           xtset hhid panel, delta(3)
          
          Panel variable: hhid (strongly balanced)
           Time variable: panel, 2016 to 2019
                   Delta: 3 units

          Comment


          • #6
            Great, thank you, Andew! This worked as well.

            Comment


            • #7
              See also https://journals.sagepub.com/doi/pdf...6867X241297950 for a detailed reminder about the importance of the delta() option with tsset or xtset.

              Comment

              Working...
              X