Announcement

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

  • Using xtreg: Number of observations too small?

    Hello everyone,
    I have a total of 202 observations for the US on a monthly basis from 2004-2017. I want to regress the monthly search volume (DSVI_country) on one independent variable (total_c), including year_month fixed effects.

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str13 country float(country_id year_month DSVI_country total_c)
    "united states" 1 529  12.667176 140
    "united states" 1 530   9.074037 162
    "united states" 1 531 -18.523067 205
    "united states" 1 532  13.853467 565
    "united states" 1 533  -6.838091 549
    end
    format %tm year_month
    I declared my data as panel data:

    Code:
    . xtset country_id year_month
    
    Panel variable: country_id (strongly balanced)
     Time variable: year_month, 2004m2 to 2020m11
             Delta: 1 month
    
    . xtdes
    
    country_id:  1, ., ..., 1                                    n =          1
    year_month:  2004m2, 2004m3, ..., 2020m11                    T =        202
               Delta(year_month) = 1 month
               Span(year_month)  = 202 periods
               (country_id*year_month uniquely identifies each observation)
    
    Distribution of T_i:   min      5%     25%       50%       75%     95%     max
                           202     202     202       202       202     202     202
    
         Freq.  Percent    Cum. |  Pattern*
     ---------------------------+--------------------------------------------------------------------------------------------------------
            1    100.00  100.00 |  22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
     ---------------------------+--------------------------------------------------------------------------------------------------------
            1    100.00         |  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
     ------------------------------------------------------------------------------------------------------------------------------------
     *Each column represents 2 periods.
    Originally, I wanted to run the regression using xtreg. However, stata returns an error:


    Code:
    . xtreg DSVI_country total_c i.year_month, fe
    no observations
    r(2000);
    I confirmed that I have no missing values and all values are non-string. Could it be that I have too few observations? Or is xtreg not working since I have a T>N panel dataset?

    I tried using xtregar as an alternative, however, it does not seem to work either:

    Code:
    . xtregar DSVI_country total_c i.year_month, fe
    time variable may not be included in varlist
    r(198);
    Running the code above without "i.year_month" worked, but I am not sure whether in this case I am still including my year-month fixed effects?

    I would be very glad if someone could provide me with a hint on how I could run this regression including year-month fixed effects.

    Thank you so much in advance for your time!

    Samuel



  • #2
    I am a bit confused, why would you run xtreg with exactly one group, one country? Maybe a time series analysis makes more sense for this purpose?
    Best wishes

    Stata 18.0 MP | ORCID | Google Scholar

    Comment


    • #3
      Dear Felix,
      thanks for your reponse and sorry for causing confusion!
      I thought about it again and I think I realized my mistake. Since I only have one group (one country), using xtreg (or xtregar) doesn't make any sense, right?
      Since I only have one country, this would probably also mean that including year-month fixed effects doesn`t make any sense either, am I right?

      Thanks for your clarifications!

      Samuel

      Comment


      • #4
        Well I think it depends, if you assume that some months or seasons have distinct effects, you can still estimate them. Did you simply try a linear OLS model (regress)?
        Best wishes

        Stata 18.0 MP | ORCID | Google Scholar

        Comment


        • #5
          Dear Felix,
          that makes sense, thank you!

          Yes, I tried a simple regress command and tried to include the year-month fixed effects.
          However, it seems that I have an issue with collinearity..

          Code:
           regress DSVI_country total_c i.year_month
          note: 730.year_month omitted because of collinearity.
          
                Source |       SS           df       MS      Number of obs   =       202
          -------------+----------------------------------   F(201, 0)       =         .
                 Model |  67354.1955       201    335.0955   Prob > F        =         .
              Residual |           0         0           .   R-squared       =    1.0000
          -------------+----------------------------------   Adj R-squared   =         .
                 Total |  67354.1955       201    335.0955   Root MSE        =         0
          
          ------------------------------------------------------------------------------
          DSVI_country | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
          -------------+----------------------------------------------------------------
               total_c |   1.583448          .        .       .            .           .
                       |
            year_month |
                  530  |    -38.429          .        .       .            .           .
          Do you have any further idea on what else I could try?

          Thanks in advance!

          Samuel

          Comment


          • #6
            This happens if you months are enumerated from, say 1 to 202 so each month is individual. Apparently, this wont work. But if you are interested in seasonal effects, you can code all Januarys as 1, Februarys as 2 and so on. Then you can estimate the effect.
            Best wishes

            Stata 18.0 MP | ORCID | Google Scholar

            Comment

            Working...
            X