Announcement

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

  • Problems with xtset because data has duplicate time values

    Hi everyone -- apologies if this is not the correct way to post, this is my first time posting and I am new to Stata. I would like to know if I can use xtset with my data. I am using Stata 15.1

    I have health expenditure data for 23 countries over a period of 6 years. The data is also split up by the source of expenditure (government, external, private) and the health area in which the expenditure is being spent (ie. HIV/AIDS/STDs, Family Planning, Contraception). I want to look at the expenditure trends for each expenditure type

    Variables:
    Country: country name
    id: 1-23
    year: 2014-2019
    expsource: Domestic general, domestic private, external
    exparea: HIV/AIDS, Maternal Conditions, Contraceptive Management
    expcapita: expenditure per capita (on each health area and by each source)

    One thing I would like to look at is the the relationship between government, external, and private expenditure over time for each of these health areas to see if I see any substitution effects (ie. are government expenditures increasing/decreasing while external and private increase/decrease). To run estimations I wanted to set my data as panel data. However, because my data repeats time values within the panel (each year appears 3 times per country (id), it does not work to use xtset and I get an error (r(451) repeated time values within panel.


    Is it possible to define multiple panels to have each time variable only appear once per id? Or is there a better way to go about this? Any help is greatly appreciated.




  • #2
    Are the variables recorded triennially or are these duplicates?

    Comment


    • #3
      You can xtset in terms of the country alone, or in terms of combinations of country and expsource, which will appease Stata. But then differences between countries for the same source, or between countries for different sources, or within country for different sources will all be treated as equivalent differences. That is a strong and perhaps implausible assumption.

      Otherwise put, when

      Code:
      xtset Country year
      fails, as it does here, the question is what commands do I intend to use that make sense (statistically, economically, epidemiologically, ...) and that require that setting to work?

      A much more positive idea -- and I am no kind of economist, etc., to know how good a solution this is -- is to reshape your data so that the three sources define three variables. Then you have a simple (country x year) layout.

      Comment

      Working...
      X