Announcement

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

  • Repeated time values within panel: time-series cross-sectional data with country & year

    Hi there,

    I am having a problem with a dataset I am using for my thesis on Stata 18. I am using the Chapel Hill Expert Survey (CHES) dataset with parties nested in countries and two time points: 2017 and 2019.
    It is my first time using panel data and, more generally, carrying out multi-level modelling. I am interested to run fixed effect models, yet I get stuck at the beginning because of the following error:

    Code:
     xtset country year, yearly
    repeated time values within panel
    r(451);

    The issue relates to the fact that each country variable is associated to multiple (different) observations (in this case, parties or better party_id). In short, country is not a unique identifier for my observations.

    Nonetheless, country is my only second level predictor and I would like to take into account the clustering effect present in the data.

    Here is a snapshot of my dataset:

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input double(country year party_id)
     3 2019  301
     3 2017  301
     3 2017  302
     3 2019  302
     3 2019  303
     3 2017  303
     3 2019  304
     3 2017  304
     3 2019  306
     3 2017  306
     3 2019  308
     3 2017  308
     3 2019  310
     3 2017  310
     3 2019  311
     3 2019  312
     3 2017  350
     3 2017  351
     4 2019  401
     4 2017  401
     4 2017  402
     4 2019  402
     4 2017  403
     4 2019  403
     4 2017  404
     4 2019  404
     4 2017  412
     4 2017  413
     4 2017  414
     4 2019  415
     4 2017  415
     4 2019  416
     4 2019  417
     4 2019  418
     4 2017  450
     5 2019  501
     5 2017  501
     5 2017  502
     5 2019  502
     5 2019  504
     5 2017  504
     5 2019  506
     5 2017  506
     5 2017  507
     5 2017  511
     5 2019  511
     5 2019  513
     5 2017  517
     5 2019  517
     5 2019  524
     5 2017  525
     5 2019  525
     5 2017  526
     5 2019  526
     5 2019  527
     5 2019  528
     5 2017  550
     5 2019  550
    end


    Suggestions would be highly appreciated.

    Thanks in advance
    Mattia

  • #2
    Mattia:
    this is not a relevant issue.
    Provided that you do not plan to use time-series operators in your -xtreg- code, you can simply -xtset- your dataset via the -panelid- only.
    This trick still makes including -i.timevar- as a predictor feasible.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Hi Carlo,

      thanks a lot for the quick answer.

      If I have understood correctly, I could go on by just coding:

      Code:
      xtset country
      While, to account for time, I should include it as a dichotomous var in the xtreg I will perform.

      Thanks

      Mattia

      Comment

      Working...
      X