Announcement

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

  • Needing to remove data to be able to xtset data

    Hello Statalist.

    I am working with a big panel-dataset tracking political regime changes. I would like to use fixed effects in my model, using the 'xtmlogit' command, however that requires me to xtset my data. As my data example shows, there are a few times where there is more than one regime change pr year, which of course means I can't xtset my data without removing "duplicates". Is there any way around this, or do you have any ideas doe other ways to go about this, as I would very much like to avoid having to remove these instances.

    clear
    input double(country_id year regchange)
    3 1900 0
    3 1901 0
    3 1902 0
    3 1903 0
    3 1904 0
    3 1905 0
    3 1906 0
    3 1907 0
    3 1908 0
    3 1909 0
    3 1910 0
    3 1911 1
    3 1911 0
    3 1911 1

    3 1912 0
    3 1913 0
    3 1913 1
    3 1914 0
    3 1914 1

    Thanks in advance.

  • #2
    As long as you are not using time series operators (lags, leads, differences), you can xtset with the panel identifier only.

    Code:
    xtset country_id

    Comment


    • #3
      Thank you for your reply. I was in fact planning on using a lagged dependent variable (regime change). Will I have to avoid that?

      Comment


      • #4
        You do not have panel data as things stand, so you won't be able to use a lagged dependent variable. Given that your variable is regime change, you may be interested in one of two things:

        1. Was there a change of regime in a given country and year?

        Code:
        collapse (max) regchange, by(country_id year)
        or

        2. How many times (frequency) was there a change of regime in a given country and year?

        Code:
        collapse (sum) regchange, by(country_id year)

        I do not see any advantage of having the data in its current form given that you are able to aggregate it as above. For the other variables, you need to figure out what form of aggregation makes sense. In this way, you will be able to use a lagged outcome.

        Comment

        Working...
        X