Announcement

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

  • numberic variables but still no observatiosn error

    I am using xtreg panel data regressions but I am receiving "No observations" r 2000 error. Visually, there is data but when i looked at the type of each variable it was numeric (byte, long, int format). I am new to stata. can someone give me the steps needed to overcome the error?

  • #2
    Hello Wesso,

    Welcome to the Stata Forum.

    Please present the commands and output under CODE delimiters, as recommended in the FAQ.

    You may rest assured that is the best way to get helpful advice for your query.
    Best regards,

    Marcos

    Comment


    • #3
      Let me add my welcome and expand on Marco's advice.

      Please 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.

      In your case, it might be helpful to show us the output of the following commands, where I'm letting y x1 x2 x3 t p represent your dependent variable, independent variables, time variable, and panel variable.
      Code:
      xtset
      describe y x1 x2 x3 t p
      misstable summarize y x1 x2 x3 t p

      Comment


      • #4
        Thanks for your fruitful comments. below is the output of the commands suggested by Willimam

        Code:
        . xtreg lc2 L.miss L.tedspread L.avgeqcgta L.sigmaroa L.ue1 L.ue2 L.merger
        no observations
        r(2000);
        
        . xtset
               panel variable:  id (unbalanced)
                time variable:  dt, 35155 to 42369, but with gaps
                        delta:  1 unit
        
        .
        . describe lc2 L.miss L.tedspread L.avgeqcgta L.sigmaroa L.ue1 L.ue2 L.merger  dt id
        factor variables and time-series operators not allowed
        r(101);
        
        .
        . misstable lc2 L.miss L.tedspread L.avgeqcgta L.sigmaroa L.ue1 L.ue2 L.merger  dt id
        misstable lc2 unrecognized
            valid misstable subcommands are summarize, patterns, tree, and nested
        r(198);

        Comment


        • #5
          Three problems:
          • Your dates are wrong. 35155 is 01apr2056! To check it, type display %d 35155
          • Why? because you copied them as excel dates. 35155 in excel is 31mar1996
          • From this blogpost ( http://blog.stata.com/2011/01/05/usi...ther-software/ ) I can see that the fix is to type gen statadate = dt + td(30dec1899) followed by format %td statadate (assuming your initial variable is called "dt")
          • There is another problem still. Your data is in monthly frequency, not daily! Which explains the lack of obs and the gaps. To fix it, run gen monthly_date = mofd(statadate) and format %tm monthly_date
          Further:
          • You can't describe time-prefixed variables (AKA tsvars AKA the stuff with the dots). So don't do describe L.miss, do describe miss
          • You typed the command that William suggested incorrectly. The correct command is misstable summarize ... (you forgot the summarize part!)
          As an advice, don't ignore the error commands given by stata, they are often quite useful (as with the misstable error message)

          Best,
          S

          Comment


          • #6
            Wesso:
            see -help misstable- for the correct syntax (-misstable. per se does not give you back anything; you should select the lacking subcommand (-summarize-; -patterns-; -tree-; -nested-).
            That said, I would check whether your original issue depends on the way lagged variables are created.

            PS: crossed in the cyberspace with Sergio's helpful reply.
            Kind regards,
            Carlo
            (Stata 18.0 SE)

            Comment


            • #7
              William suggested misstable summarize and you omitted the summarize.

              Stata is telling you what you is wrong with your describe command.

              But the xtset output is telling you the problem.

              The problem is the gaps. You have a time variable that runs from 35155 to 42369. I have no idea what that means as, for example,

              Code:
              . di %td 42369
              01jan2076
              42369 would be an unlikely daily date, and I can't see that it is any other standard kind of date either.

              But idiosyncratic time variables are allowed. The problem is that the L. operator says "use the previous value", so for date 42369 you must have non-missing values for date 42368, etc., and Stata is telling you that all your observations fail here.

              There are various possible diagnoses, the worst of which is that you can't use panel models because your time variable won't allow it. But to be sure we need to know more about your time variable. For example, show us the results of

              Code:
              sort id dt 
              list dt if id == id[1]
              and (probably most important) explain what that time variable is.

              Comment


              • #8
                What we tell you three times is true.

                Comment


                • #9
                  Thanks again. The data is quarterly data . I fixed the date format and the misstable error . below is the output
                  Code:
                  . xtset
                         panel variable:  id (unbalanced)
                          time variable:  statadate, 31mar1996 to 31dec2015, but with gaps
                                  delta:  1 day
                  
                  .
                  . describe lc2 miss tedspread avgeqcgta sigmaroa ue1 ue2 merger  statadate id
                  
                                storage   display    value
                  variable name   type    format     label      variable label
                  -----------------------------------------------------------------------------------------------------------------------------------
                  lc2             float   %9.0g                 
                  miss            float   %9.0g                 
                  tedspread       float   %9.0g                 TedSpread
                  avgeqcgta       float   %9.0g                 AvgEqCgta
                  sigmaroa        float   %9.0g                 SigmaROA
                  ue1             float   %9.0g                 Linear prediction
                  ue2             float   %9.0g                 Linear prediction
                  merger          byte    %8.0g                 Merger
                  statadate       float   %td                   
                  id              long    %12.0g                ID
                  
                  .
                  . misstable summarize lc2 miss tedspread avgeqcgta sigmaroa ue1 ue2 merger  statadate id
                                                                                 Obs<.
                                                                  +------------------------------
                                 |                                | Unique
                        Variable |     Obs=.     Obs>.     Obs<.  | values        Min         Max
                    -------------+--------------------------------+------------------------------
                             lc2 |   840,640              15,342  |   >500   -.818356    18.97061
                            miss |   846,071               9,911  |      2          0           1
                       tedspread |   840,640              15,342  |     49      .0015       .0245
                       avgeqcgta |   846,260               9,722  |   >500   .0013602     1688.72
                        sigmaroa |   846,809               9,173  |   >500   .0004551    10.96331
                             ue1 |   847,624               8,358  |   >500  -.0095701    .0328183
                             ue2 |   847,205               8,777  |   >500   .0053306    .0056019
                          merger |   840,640              15,342  |      2          0           1
                    -----------------------------------------------------------------------------

                  Comment


                  • #10
                    No; changing the date display format is not sufficient here.

                    xtset is still telling you that it thinks you have daily data (that's because you informed it of a daily date variable) and still telling you that you have gaps.

                    It seems that you have daily dates but the daily dates are the last day of each quarter. So, this is what you should try

                    Code:
                    gen qdate = qofd(statadate) 
                    format qdate %tq 
                    xtset id qdate 
                    All of the key principles are documented, e.g.

                    Code:
                    help dates

                    Comment


                    • #11
                      Wesso:
                      as a general remark, you seemingly have lots of missing values.
                      All regression models would pay a high price for this via listwise deletion.
                      As usual (and with the usual methodological issues) -mi- or -ipolate- might be worth considering.

                      PS: crossed in the cyberspace with Nick's helpful reply.
                      Kind regards,
                      Carlo
                      (Stata 18.0 SE)

                      Comment


                      • #12
                        many thanks. it is working after incorporating Nick's suggestion

                        Comment


                        • #13

                          Just a subtle observation: when we type just - xtset - , as you did in #4 and #9 , we are just showing how the dataset was "xtsetted". In fact, you were able to present - xtset - after - xtreg - precisely because of this. To declare the dataset is a panel data (i.e.,before performing the - xtreg - ), we are supposed to type - xtset panelvar - at least, and preferrably adding the time variable as well.
                          Best regards,

                          Marcos

                          Comment


                          • #14
                            Hi
                            This is a new post

                            I have a panel data set 9 years and 11 banks.
                            I type:

                            xtset bank year
                            panel variable: bank(unbalanced)
                            time variable: year, 2006 to 2014
                            delta: i unit

                            When I run a regression using:
                            xtreg trev asst eqasst rskasst
                            The following output comes out:

                            No of obs = 99
                            No of groups = 12

                            Why do I have 12 groups when I have 11 banks?
                            Please advise

                            tinfah

                            Comment


                            • #15
                              Tinfah:
                              welcome to the list.
                              Please start a new thread. Thanks.
                              You might be inspired by the previous replies.
                              If the problem still persists, please post in a more effective way, acting on FAQ advice. Thanks again.
                              Last edited by Carlo Lazzaro; 03 Feb 2017, 11:08.
                              Kind regards,
                              Carlo
                              (Stata 18.0 SE)

                              Comment

                              Working...
                              X