Announcement

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

  • Set dataset as a panel

    Hello,

    I have the problem to set my dataset as a panel because I have repeated time values within my panel.

    My dataset looks something like the table below, the problem is that I have each observation seperatly and not all observations for each year and quarter like 2007/Q1, 2007/Q2 and so on

    That's why I get the error "repeated time values within my panel". Is it possible to merge all 2007 Q1 observations together (to sum it up) or is there another way to use may data as a panel?

    Code:
     
    age countrydummy year quartal country educ nat
    42 1 2007 Q1 AT 2 nat
    5 1 2007 Q1 AT 1 EU
    66 1 2007 Q1 AT 3 nat
    33 1 2007 Q1 AT 1 EU
    2 1 2007 Q2 AT 2 nat
    Thank you,
    best regards
    Ruth

  • #2
    Ruth:
    if you do not plan to use time-series commands, you can simply -xtset- your dataset with -panelid- only:
    Code:
    xtset panelid
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Thank you Carlo,

      but actually I want to run a gmm regression with the data, does it work withou setting my data as a panel?

      Best regards,
      Ruth

      Comment


      • #4
        Ruth:
        sorry, I'm not familiar with -gmm-.
        My previous reply referred to -xtset- in general.
        Anyway, you may try and see what happens.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          gmm is not a specific estimator - it is a general method that has been implemented in many different estimators for different situations. For example, xtivreg2 offers a gmm estimator - it would require a panel setup. But ivreg2 also offers a gmm estimator but does not use a panel set up. xtabond and related estimators (given xt prefix) require panel set ups as far as I know. But I suspect they require setting both panel and date since they rely on lags as instruments.

          It is possible to use collapse to change to one observation per country-year if that makes sense in your context.

          Comment


          • #6
            In order to set your data as a panel, you need a panel variable (and a time variable). You should first decide what your panel variable is. Next, depending on your context, you can also use the combination of the year and the quarter as the time variable for your panel (if time variable is necessary).

            Comment


            • #7
              Thank you.
              My panel variable is country or countrydummy and my time variable should be year, but the problem ist that I have multiple observations on the same year within country. I don't know how to solve this probleme. I want to use xtabond for my gmm regression. I will try now the command collapse.

              Comment


              • #8
                I had a similar problem to yours. The command I used was same for as above, but instead of set date yearly, I set date daily:

                Code:
                xtset country_variable date_variable, daily

                Comment


                • #9
                  Thank you but I tried this code before and then I got the error "repeated time values within panel "

                  Comment


                  • #10
                    Then, you need to investigate the duplicates.
                    PHP Code:
                    Code
                    duplicates tag [varlist] [if] [in] , generate(newvar

                    Comment

                    Working...
                    X