Announcement

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

  • Fixed Effects Regression (how to fix error:repeated time values within panel)

    Hey listers, how can I fix the error: repeated time values within panel?
    xtset FundId date
    xtreg dependent variable indepent variables, fe

    With:
    duplicates drop FundId date, force
    prior to the code I can do the regression, but I think this does not make sense because it drops so much observations, how can I do the regression?
    I would be grateful if someone could help me with this.

  • #2
    It would be useful if you can put the Stata output of the error along with the command used.

    Also the code of error that comes with the output.

    As a simple check. maybe your data has for same id variables the same year. which probably can cause troubles among the lecture. Or maybe, the time variable it's actually non-changing.
    Last edited by John Riveros; 11 Dec 2018, 07:41.

    Comment


    • #3
      So the error is the following:
      repeated time values within panel
      r(451);

      I have a dataset like this:
      fundID date return other variables of the fund.....
      1 1 0,3
      1 2 0,5
      2 1 0,1
      2 2 0,2
      3 1 0,8
      3 2 0,09
      3 3 0,5
      I want to make a regression but I do not want to drop some much data (from 2mio to 10 thousand observations)
      Last edited by John Lei; 11 Dec 2018, 08:37.

      Comment


      • #4
        Hi John Lei,
        I think the main question is if your data is indeed panel data where fundID is your panel id and data your date id.
        when using "duplicates drop FundId date, force" you are keeping the unique combinations between Fundid and date. However, since you say that is not what you want, maybe that you have another ID variable, or a different time variable.
        So, some basic questions are:
        - What is your data Frequency? is that being captured by "date"
        - What is your Panel id? is FundId identifying the panel id?
        - if you have duplicates, Why are they in the data at all?
        For the the last question, something i do its the following:

        Code:
        egen iddata=group(Fundid date)
        bysort iddata:gen Nobs=_N
        edit if Nobs>1
        Then simply look why you have more than 1 observation per "iddata".

        Hope this helps
        Fernando

        Comment


        • #5
          Try things like
          Code:
          duplicates report fundID date
          and
          Code:
          duplicates examples fundID date
          and other commands described in the output of
          Code:
          help duplicates
          If you don't want to drop so much data, you have to correct your misunderstanding of the data, since Stata is telling you that for some funds you have multiple observations of the same fund on the same date. Or, perhaps that is correct, and the date doesn't matter, in which case you have panel data rather than longitudinal data and
          Code:
          xtset fundID
          may be adequate for your needs.

          Comment


          • #6
            John:
            if the repeated time values within the same panel do not refer to duplicate observations and you do not plan to use time-series commands, such as lags and leads, you can simply -xtset- your data with the -panelid- and go -xtreg-.
            Kind regards,
            Carlo
            (Stata 18.0 SE)

            Comment


            • #7
              i have so much duplicates of combination FundID and date because I also have the variable stock so every fund will hold more than one Stock in a given month (date). I do not know if this helps you guys to solve my problem, but thanks alot so far.

              Comment


              • #8
                Without knowing more about the model you hope to fit, it's impossible to advise you on how to treat your data.
                Code:
                xtreg dependent variable indepent variables, fe
                really doesn't tell us anything other than that you hope to use xtreg. And you weren't any more helpful in your post from yesterday on this same topic.
                Hey my regression does not work
                does not tell us anything helpful.

                At this point it's time for you to review the Statalist FAQ linked to from the top of the page, as well as from the Advice on Posting link on the page you used to create your post. Note especially sections 9-12 on how to best pose your question.

                The more you help others understand your problem, the more likely others are to be able to help you solve your problem.

                Comment


                • #9
                  Sorry I am new to Stata and not a researcher or anything so I just hope that somebody understands my problem and can help me. Most of the time this worked out pretty well til now, but I try to improve.

                  Comment


                  • #10
                    John:
                    as already replied in ##5 and 6, I would consider -xtset-ting your data with -panelid- only and go -xtreg-.
                    Kind regards,
                    Carlo
                    (Stata 18.0 SE)

                    Comment

                    Working...
                    X