Announcement

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

  • Insufficient Observations Error

    I keep encountering the insufficient obs error using xtreg even after eliminating duplicates and blanks as suggested in prior posts. I assume it is a newbie mistake.
    This is the simple code I am using after importing the excel file:
    global t CalDate
    global id ID
    sort $t $id
    xtset $id $t
    * Global Vars
    global ylist MVBest
    global xlist GrossRD GM
    xtsum $id $t $ylist $xlist
    xtreg $ylist $xlist
    Attached Files

  • #2
    Your code could be slimmed down to


    Code:
    xtset ID CalDate 
    xtsum ID CalDate MVBest GrossRD GM
    xtreg MVBest GrossRD GM
    The indirection of globals is neither needed nor helpful.

    You need please to show us a data example using dataex as explained at FAQ Advice #12, which also explains multiple reasons why spreadsheet attachments are deprecated here.

    Comment


    • #3
      ID is simply a sequence of CalDate, but the start of the sequence is different for each firm.

      Thus, your FE include an indicator for each and all observations.

      try

      Code:
      egen id = group(Ticker)
      
      xtset id CalDate
      
      xtreg MVBest GrossRD GM, fe

      Comment


      • #4
        Thank you all sincerely. I]After taking suggestions, I still get insufficient obs when I run xtreg, a good regression when I run xtreg..., be, and a collinear error when I run xtreg..., fe, even with ONE x variable!

        I have tried Nick's approach but I get the same result. I will review dataex and submit that file as suggested. Thanks for your patience.

        George, I tried your method, same results, but maybe identified the problem? Let me share that I get collinearity when I run fixed effects, so I tried a run with only one 'x' variable.

        Two things:
        (1) The between regression with 'xtreg mvbest grossrd, be' runs fine. The error I get with the "xtreg mvbest grossrd, fe" regression is "note: grossrd omitted because of collinearity."
        Now I don't understand how I can get multicollinearity with one x variable. What can it be collinear with? There is nothing else on the independent variable side.
        Could the single x variable being eliminated (or both of them before) due to collinearity lead to my insufficient observations error on the straight "xtreg mvbest grossrd"?
        How can I fix this error when there is no second x variable to delete?

        (2) The other question is I do not see your point on the id. Let me explain. I have a unique ticker for each stock (as in your 'egen') but it is alphanumeric.
        Since Stata was not working with use of the alpha characters in tickers I created a numerical ticker id to try to get it to work. You are correct it is an individual id for each stock by each date 'caldate.'

        Is that a problem for fe - I was not sure what your comment was saying was wrong "Thus, your FE include an indicator for each and all observations."
        In fixed effects here, the stock prices will oc course have many the same months in common, so are you saying these will all be eliminated by the 'fe' mode?
        In that case, could I just use an id number that is just the sequential line number for the excel row, like row 1 to 183?' If the egen solves that, then it's fine.

        Thanks again.

        Comment


        • #5
          Tony:
          as far as your point #1 is concerned, the collinearity is with the fixed effect.
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment

          Working...
          X