Announcement

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

  • "Insufficient Observations" error with random effects model



    I have a minor technical inquiry on how to deal with "insufficient observations" with random effects model in panel setup. The details are provided below.

    I am working with multiple countries, multiple commodities and multiple year panel (trade) data (with repeated observations) in each case. I have also a single dependent variable in each case and multiple explanatory variables as I have shown below in the loop. I am running a Hausman test with sigmamore option using this loop. While I am able to run the fixed effects model estimates at commodity level alright, the random effects model shows an error — "insufficient observations".

    I am dealing with country level data (reporter_code=360). And I have been able to generate fixed effects estimates using the following loop. However, the random effect has not been able to generate the estimates. Instead, I obtained the error —"insufficient observations".

    By examining the outputs from fixed effects model, I have established on average there are about 200 observations per commodity in majority of cases. I have also considered the number of explanatory variables just so that I have sufficient observations in each case. However, the random effects model is not working even when I considered one or two explanatory variables. It generates instead —"insufficient observations".

    I have isolated a single country trade data (as opposed to multiple country data) to mitigate the problem of missing data. I have also cleaned missing data at country and commodity level. I am running the regression country by country using the command as shown below in the loop.


    local econvars var1 var2 var3 var4 var5 var6 /*group of explanatory variables*/
    local geogvars var1 var2 var3 var4 /*group of explanatory variables*/
    local policyvars var1 var2 var3 var4 /*group of explanatory variables*/
    local RTAs var1 var2 var3 var4 /*group of explanatory variables*/
    local var1 var2 var3 var4 /*group of explanatory variables*/
    local var1 var2 /*group of explanatory variables*/
    local reporter_code = "360" /*country code*/


    foreach num of local reporter_code{ /*country level */
    foreach year of varlist periodI periodII periodIII { /*each period represents eight years in each case*/
    foreach var of varlist comcode1-comcode24 comcode26-comcode64 comcode66{ /*comcode are dummies, total of 66*/
    di "reporter_code=`num'"
    di "year=`year'"
    di "commodity_code=`var'"
    capture noisily xtreg DependentVariable `econvars' `geogvars' `policyvars' `RTAs' `culturvars' IMR`var'_`year'_360 i.`year' c.fdiinflows#c.`var' if reporter_code==`num' & `year'==1 & `var'==1,fe
    estimates store fixed
    capture noisily xtreg DependentVariable `econvars' `geogvars' `policyvars' `RTAs' `culturvars' IMR`var'_`year'_360 i.`year' c.fdiinflows#c.`var' if reporter_code==`num' & `year'==1 & `var'==1,re
    estimates store random
    hausman fixed random,sigmamore

    }
    }
    }


    I would like your suggestions to address this problem.










  • #2
    You'll increase your chances of a helpful answer by following the FAQ on asking questions - provide Stata code in code delimiters, readable Stata output, and sample data using dataex. Also, try to simplify your question as much as possible.

    It seems very strange that you'd get a fixed effects model to estimate but not the random effects one. I'd start by making absolutely certain that the statements are identical except for re/fe. Copy and paste the fe and change it to re. If it still gives you that error, I'd find out which set of variables causes the problem. See if you run that outside the loop whether the problem occurs. Also try set trace on - this will tell you exactly how Stata is interpreting all your locals. It is possible that there is something different in the two statements that is not obvious on inspection.

    Comment


    • #3
      Thanks for your prompt reply. I have examined the data further using your suggestions. The problem remains and I have the following questions.

      I have checked the two outside loops in the above command for random effects model (REM) and fixed effects model (FEM). They both work fine. The problem is in the third and inside loop at the commodity level. A simplified version of the command above rewritten with code delimiters looks as follows. While my dependent variable is ln_tradevalues, I have reduced the number of explanatory variables to five (ln_gdpi, ln_gdpj and ln_dist ln_opennessi ln_reer ln_tariffmanji ) for simplicity. I have also made slight changes in the formulation for the sake of presentation.

      Code:
       
      local econvars ln_gdpi ln_gdpj 
      local geogvars ln_dist ln_opennessi ln_reer ln_tariffmanji 
      local reporter_code="360"
      
      foreach num of local reporter_code{
      foreach wave of varlist periodI {
      egen cc=group(commodity_code)
      forvalues i=1/66{ 
        di "reporter_code=360"
        di "year=`wave'"
        di "commodity_code=`i'"
       capture noisily xtreg ln_tradevalues `econvars' `geogvars'  if reporter_code==`num' & `wave'==1 & cc==`i',fe
       estimates store fixed
       capture noisily xtreg ln_tradevalues `econvars' `geogvars'  if reporter_code==`num' & `wave'==1 & cc==`i',re
       estimates store random
       hausman fixed random,sigmamore
        
       }
       }
       }
      The two outer loops work fine with both FEM and REM , probably because they make use of a bigger data. The problem is with the third and inner loop
      Code:
      egen cc=group(commodity_code)
      forvalues i=1/66{
      .

      I would like to know why REM is not working while FEM is working fine with the third and inner loop? Is it problem of "missing observations"? if so I would like to get a command to skip "missing observations"?

      I have also provided below a sample data for you examination. Your help in resolving this problem is greatly appreciated.

      Code:
       . dataex reporter_code year commodity_code ln_tradevalues ln_gdpi ln_gdpj ln_dist ln_opennessi ln_reer ln_tariffmanji cc if repor
      > ter_code==360 & periodI==1
      
      ----------------------- copy starting from the next line -----------------------
      
      
      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input int(reporter_code year) long commodity_code float(ln_tradevalues ln_gdpi ln_gdpj ln_dist ln_opennessi ln_reer ln_tariffmanji cc)
      360 1997 1 10.334912 26.09738  26.80113   8.78954 4.025242     .2042029 2.0347056 1
      360 1997 1  7.663408 26.09738         .         . 4.025242    .09709425         . 1
      360 1997 1  6.620073 26.09738 27.506817  9.177189 4.025242   -.12267182   2.70805 1
      360 1997 1  10.45677 26.09738 27.204575  8.426888 4.025242    .25171432 1.9286187 1
      360 1997 1  13.42819 26.09738  27.59187    6.5248 4.025242    .02641632    2.8088 1
      360 1997 1  7.574045 26.09738 28.009943  7.834424 4.025242    .07687012  .7466879 1
      360 1997 1  9.058703 26.09738  28.42794  7.959026 4.025242    .04682441         . 1
      360 1997 1 13.473692 26.09738  25.90141  8.843048 4.025242   -.27817082         . 1
      360 1997 1  7.610358 26.09738 27.845366  7.196922 4.025242     .1249175  .7466879 1
      360 1997 1  9.036701 26.09738  29.11597  7.949428 4.025242    -.2039118  .8544153 1
      360 1997 1 12.623466 26.09738 27.046734  8.703295 4.025242    .17808238         . 1
      360 1997 1  6.683361 26.09738  24.13621  8.661741 4.025242     .0776143         . 1
      360 1997 1 13.916386 26.09738 25.328485  9.019316 4.025242   -.12945424 2.0881534 1
      360 1997 1  7.989899 26.09738         .         . 4.025242   -.21634147         . 1
      360 1997 1  9.200795 26.09738  26.74477  9.269896 4.025242    .15204906  .7466879 1
      360 1997 1  6.486161 26.09738  24.91405  9.804031 4.025242     .0933183  1.899118 1
      360 1997 1  7.985825 26.09738 24.857365  9.097412 4.025242   -.05230597         . 1
      360 1997 1  9.980449 26.09738  25.83504  9.451491 4.025242    -.1800967         . 1
      360 1997 1 16.781425 26.09738 25.330074   8.82836 4.025242   -.10327516         . 1
      360 1997 1  10.47444 26.09738 24.013296  8.469993 4.025242  -.018606618         . 1
      360 1997 1 8.5065365 26.09738  27.10117  8.448902 4.025242    .19937077  .7466879 1
      360 1997 1  7.663408 26.09738 26.381367  8.747742 4.025242 -.0003161334 -.2484614 1
      360 1997 1  11.59047 26.09738   25.7351  6.808011 4.025242  -.036436427         . 1
      360 1997 1  9.478764 26.09738 25.090673  2.080116 4.025242    .25568634         . 1
      360 1997 1  7.284821 26.09738 28.060913  7.714138 4.025242    .08651714  .7466879 1
      360 1997 1 12.228406 26.09738 29.783773  8.304964 4.025242   .024365146  1.472472 1
      360 1997 2  9.862978 26.09738  26.80113   8.78954 4.025242     .2042029 2.0347056 2
      360 1997 2  9.376786 26.09738 24.599545    8.1231 4.025242   -.10511898         . 2
      360 1997 2  15.49426 26.09738         .         . 4.025242    .09709425         . 2
      360 1997 2 13.476597 26.09738 27.204575  8.426888 4.025242    .25171432 1.9286187 2
      360 1997 2  9.556409 26.09738  27.59187    6.5248 4.025242    .02641632    2.8088 2
      360 1997 2  9.826822 26.09738  25.87966  8.573097 4.025242     .1177061  .7466879 2
      360 1997 2   14.3569 26.09738 28.009943  7.834424 4.025242    .07687012  .7466879 2
      360 1997 2 11.733377 26.09738  28.42794  7.959026 4.025242    .04682441         . 2
      360 1997 2 13.820824 26.09738  25.90141  8.843048 4.025242   -.27817082         . 2
      360 1997 2 14.400607 26.09738  29.11597  7.949428 4.025242    -.2039118  .8544153 2
      360 1997 2 12.052852 26.09738 27.046734  8.703295 4.025242    .17808238         . 2
      360 1997 2 11.955783 26.09738 25.328485  9.019316 4.025242   -.12945424 2.0881534 2
      360 1997 2 13.673436 26.09738         .         . 4.025242   -.21634147         . 2
      360 1997 2 14.751388 26.09738  26.74477  9.269896 4.025242    .15204906  .7466879 2
      360 1997 2 10.984428 26.09738  25.83504  9.451491 4.025242    -.1800967         . 2
      360 1997 2  14.38833 26.09738 25.330074   8.82836 4.025242   -.10327516         . 2
      360 1997 2  7.682022 26.09738 24.013296  8.469993 4.025242  -.018606618         . 2
      360 1997 2 10.715972 26.09738         .         . 4.025242   -.13004091         . 2
      360 1997 2  11.50956 26.09738  27.10117  8.448902 4.025242    .19937077  .7466879 2
      360 1997 2 11.682382 26.09738 28.060913  7.714138 4.025242    .08651714  .7466879 2
      360 1997 2 13.143575 26.09738 29.783773  8.304964 4.025242   .024365146  1.472472 2
      360 1997 2  6.836259 26.09738         .         . 4.025242            .         . 2
      360 1997 3  9.830916 26.09738  22.75776  8.671988 4.025242     .4810699         . 3
      360 1997 3  13.81851 26.09738  20.33851  8.178583 4.025242   -.12486845         . 3
      360 1997 3 11.956688 26.09738 24.599545    8.1231 4.025242   -.10511898         . 3
      360 1997 3  9.650143 26.09738  22.37141  8.806587 4.025242    -.1494001         . 3
      360 1997 3 11.232205 26.09738         .         . 4.025242            .         . 3
      360 1997 3 10.514882 26.09738 23.437426  9.164284 4.025242    .09602748  2.957511 3
      360 1997 3 11.358165 26.09738  25.87966  8.573097 4.025242     .1177061  .7466879 3
      360 1997 3  12.05897 26.09738  25.90141  8.843048 4.025242   -.27817082         . 3
      360 1997 3 11.289607 26.09738  29.11597  7.949428 4.025242    -.2039118  .8544153 3
      360 1997 3 11.585107 26.09738 24.147484  9.165332 4.025242   -1.3646783         . 3
      360 1997 3 14.196774 26.09738 25.328485  9.019316 4.025242   -.12945424 2.0881534 3
      360 1997 3    8.1873 26.09738  20.04643  7.726083 4.025242   -.14636973         . 3
      360 1997 3  14.01465 26.09738         .         . 4.025242   -.21634147         . 3
      360 1997 3 11.729785 26.09738  26.74477  9.269896 4.025242    .15204906  .7466879 3
      360 1997 3 11.628234 26.09738 24.857365  9.097412 4.025242   -.05230597         . 3
      360 1997 3  9.867653 26.09738 26.740204  9.089468 4.025242     .1565961  3.368674 3
      360 1997 3  13.27011 26.09738 25.330074   8.82836 4.025242   -.10327516         . 3
      360 1997 3 11.702678 26.09738   25.7351  6.808011 4.025242  -.036436427         . 3
      360 1997 3  9.762212 26.09738 28.060913  7.714138 4.025242    .08651714  .7466879 3
      360 1997 3 10.631036 26.09738 29.783773  8.304964 4.025242   .024365146  1.472472 3
      360 1997 3  5.774551 26.09738         .         . 4.025242            .         . 3
      360 1997 4  6.395262 26.09738  26.40296  8.924015 4.025242    -.6539977  2.703373 4
      360 1997 4 15.726418 26.09738  26.80113   8.78954 4.025242     .2042029 2.0347056 4
      360 1997 4  8.517193 26.09738 22.571594  7.485274 4.025242    -.1515485         . 4
      360 1997 4 12.669397 26.09738 24.599545    8.1231 4.025242   -.10511898         . 4
      360 1997 4 16.597994 26.09738         .         . 4.025242    .09709425         . 4
      360 1997 4  9.539285 26.09738  22.37141  8.806587 4.025242    -.1494001         . 4
      360 1997 4 13.420197 26.09738  23.13879  9.008784 4.025242     .5488101  .7466879 4
      360 1997 4 14.946366 26.09738 27.204575  8.426888 4.025242    .25171432 1.9286187 4
      360 1997 4 13.965446 26.09738 23.437426  9.164284 4.025242    .09602748  2.957511 4
      360 1997 4 10.468034 26.09738 25.165356  9.340189 4.025242    -.0896458  2.396986 4
      360 1997 4 18.382824 26.09738  27.59187    6.5248 4.025242    .02641632    2.8088 4
      360 1997 4  7.021084 26.09738 21.566004  8.392752 4.025242     .1814514  2.835564 4
      360 1997 4 11.410395 26.09738 22.984434  9.389449 4.025242    .16102946  .7466879 4
      360 1997 4 14.737317 26.09738  25.87966  8.573097 4.025242     .1177061  .7466879 4
      360 1997 4  12.18356 26.09738 19.319954  6.985282 4.025242   -.06439879         . 4
      360 1997 4  6.744059 26.09738  25.56614  7.809607 4.025242    .05202725  .7466879 4
      360 1997 4 16.418621 26.09738 28.009943  7.834424 4.025242    .07687012  .7466879 4
      360 1997 4 16.072308 26.09738  28.42794  7.959026 4.025242    .04682441         . 4
      360 1997 4   11.0852 26.09738 22.653526  8.466738 4.025242   -.13089259         . 4
      360 1997 4 11.795303 26.09738         .         . 4.025242            .         . 4
      360 1997 4  13.19357 26.09738 25.687214  8.303186 4.025242     .1153412  .7466879 4
      360 1997 4 11.645172 26.09738  22.05399  6.917286 4.025242    -.3213585         . 4
      360 1997 4  17.68068 26.09738  25.90141  8.843048 4.025242   -.27817082         . 4
      360 1997 4  6.907755 26.09738   24.5772   8.86007 4.025242     .4367319  .7466879 4
      360 1997 4  11.73405 26.09738 25.458754  8.899204 4.025242    -.5425546         . 4
      360 1997 4 11.641293 26.09738 25.139896  7.098598 4.025242     .1975034  .7466879 4
      360 1997 4 12.747137 26.09738 27.845366  7.196922 4.025242     .1249175  .7466879 4
      360 1997 4  20.64317 26.09738  29.11597  7.949428 4.025242    -.2039118  .8544153 4
      360 1997 4 14.369223 26.09738  22.70374 8.2586975 4.025242    .05686288         . 4
      360 1997 4 16.512074 26.09738 27.046734  8.703295 4.025242    .17808238         . 4
      360 1997 4 8.1847925 26.09738  21.28117  9.232161 4.025242  -.064748734         . 4
      end
      label values commodity_code ncommodity_code
      label def ncommodity_code 1 "00", modify
      label def ncommodity_code 2 "01", modify
      label def ncommodity_code 3 "02", modify
      label def ncommodity_code 4 "03", modify
      ------------------ copy up to and including the previous line ------------------

      Comment


      • #4
        Code:
        The code for periodI in the above sample data is a set of dummy variables of value one.

        Comment


        • #5
          I'm going to venture a guess here. I think the problem is that when you put all three loops together, you are constraining the estimation sample to a single panel (panel referring to the variable with which the data was -xtset-). -xtreg, fe- tolerates that, but -xtreg, re- does not. See this simple example:

          Code:
          . webuse nlswork, clear
          (National Longitudinal Survey.  Young Women 14-26 years of age in 1968)
          
          . xtset
                 panel variable:  idcode (unbalanced)
                  time variable:  year, 68 to 88, but with gaps
                          delta:  1 unit
          
          . 
          . xtreg ln_wage i.union c.tenure, fe
          
          Fixed-effects (within) regression               Number of obs     =     19,010
          Group variable: idcode                          Number of groups  =      4,134
          
          R-sq:                                           Obs per group:
               within  = 0.1030                                         min =          1
               between = 0.1923                                         avg =        4.6
               overall = 0.1407                                         max =         12
          
                                                          F(2,14874)        =     853.80
          corr(u_i, Xb)  = 0.1426                         Prob > F          =     0.0000
          
          ------------------------------------------------------------------------------
               ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
          -------------+----------------------------------------------------------------
               1.union |    .098657   .0070936    13.91   0.000     .0847526    .1125614
                tenure |   .0262867   .0006891    38.15   0.000     .0249361    .0276373
                 _cons |   1.629107   .0036535   445.90   0.000     1.621946    1.636268
          -------------+----------------------------------------------------------------
               sigma_u |   .4004797
               sigma_e |   .2598383
                   rho |  .70374743   (fraction of variance due to u_i)
          ------------------------------------------------------------------------------
          F test that all u_i=0: F(4133, 14874) = 9.16                 Prob > F = 0.0000
          
          . xtreg ln_wage i.union c.tenure, re
          
          Random-effects GLS regression                   Number of obs     =     19,010
          Group variable: idcode                          Number of groups  =      4,134
          
          R-sq:                                           Obs per group:
               within  = 0.1029                                         min =          1
               between = 0.1925                                         avg =        4.6
               overall = 0.1411                                         max =         12
          
                                                          Wald chi2(2)      =    2436.32
          corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =     0.0000
          
          ------------------------------------------------------------------------------
               ln_wage |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
          -------------+----------------------------------------------------------------
               1.union |   .1188247   .0066354    17.91   0.000     .1058195    .1318298
                tenure |   .0291368   .0006537    44.57   0.000     .0278556    .0304181
                 _cons |   1.598271   .0065335   244.63   0.000     1.585466    1.611076
          -------------+----------------------------------------------------------------
               sigma_u |  .35528064
               sigma_e |   .2598383
                   rho |  .65151314   (fraction of variance due to u_i)
          ------------------------------------------------------------------------------
          
          . 
          . //      THIS RUNS
          . xtreg ln_wage i.union c.tenure if idcode == 1, fe
          
          Fixed-effects (within) regression               Number of obs     =          7
          Group variable: idcode                          Number of groups  =          1
          
          R-sq:                                           Obs per group:
               within  = 0.3932                                         min =          7
               between =      .                                         avg =        7.0
               overall = 0.3932                                         max =          7
          
                                                          F(2,4)            =       1.30
          corr(u_i, Xb)  =      .                         Prob > F          =     0.3682
          
          ------------------------------------------------------------------------------
               ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
          -------------+----------------------------------------------------------------
               1.union |    .507071   .4367341     1.16   0.310    -.7054972    1.719639
                tenure |   .0825526   .0969302     0.85   0.442    -.1865688    .3516739
                 _cons |   1.654852   .4214911     3.93   0.017     .4846048    2.825099
          -------------+----------------------------------------------------------------
               sigma_u |          .
               sigma_e |  .39561972
                   rho |          .   (fraction of variance due to u_i)
          ------------------------------------------------------------------------------
          F test that all u_i=0: F(0, 4) = .                           Prob > F =      .
          
          . 
          . //      THIS DOES NOT
          . xtreg ln_wage i.union c.tenure if idcode == 1, re
          insufficient observations
          r(2001);
          I believe the explanation for this is something like this: the re estimator is a weighted average of the -fe- estimator and the -be- estimator. If the estimation sample contains only a single panel, then the -be- regression has only a single observation, and hence can't be estimated (unless there are no independent variables at all)--it has insufficient observations.

          Comment


          • #6
            Thank you very much for the insight. I would consider the next level up for my analysis. My question now is can I simply use fixed effects model at that detailed level when the random effects model is not possible (since Hausman test is not possible)?

            Comment


            • #7
              Well, if my explanation of the problem is the correct one, the question you are asking becomes irrelevant. If the analysis is restricted to a single panel, then you are no longer working with two-level data and it is really just an OLS regression. There is no issue of fixed vs random effects. The fixed estimator that ran is just giving you an OLS regression and calling it a FE regression. But that is an illusion, not a reality. The resulting analysis is neither fixed nor random effects, as it is just one-level data and the distinction is meaningless.

              Comment


              • #8
                Thank you again. I have taken your original advice on board. Hence, I have grouped SITC2 level items at the next higher level (SITC 1) level. Consequently, I have been able to produce estimates for both random effects model (REM) and fixed effects model (FEM).

                Comment


                • #9
                  Follow up Question - I have used the following command to group panels together (SITC2 into SITC1 level, with the latter being the aggregate of the former) as per your advice. However, I have obtained implausible results under the FEM and REM as can be seen (below) by examining the BETWEEN variations under both models. How could I formulate my commands under the fixed effects model (FEM) and random effects model (REM) to avoid these problems?



                  I first grouped the panel based on the index numbers in column three above which I call com_code (cc).
                  I also run the
                  xtreg, fe; and
                  xtreg re
                  based on the following commands:


                  Code:
                  gen panel_com=0
                  replace panel_com=1 if cc<11
                  replace panel_com=2 if cc>10 & cc<13
                  replace panel_com=3 if cc>12 & cc<22
                  replace panel_com=4 if cc>21 & cc<26
                  egen panelset=group(reporter_code panel_com year)
                  sort panelset
                  by panelset:gen sum2=sum(1)
                  xtset panelset sum2
                  (command #1)


                  Code:
                  local econvars ln_gdpi ln_gdpj
                  local geogvars ln_dist ln_opennessi ln_reer ln_tariffmanji
                  local reporter_code="360"
                  
                  foreach num of local reporter_code{
                  foreach wave of varlist periodI {
                  egen cc=group(commodity_code)
                  forvalues i=1/66{
                    di "reporter_code=360"
                    di "year=`wave'"
                    di "commodity_code=`i'"
                  capture noisily xtreg ln_tradevalues `econvars' `geogvars'  if reporter_code==`num' & `wave'==1 & cc<11,fe
                  estimates store fixed
                  capture noisily xtreg ln_tradevalues `econvars' `geogvars'  if reporter_code==`num' & `wave'==1 & cc<11,re
                  estimates store random
                  hausman fixed random,sigmamore
                   
                  }
                  }
                  }
                  (command #2)

                  Code:
                  local econvars ln_gdpi ln_gdpj
                  local geogvars ln_dist ln_opennessi ln_reer ln_tariffmanji
                  local reporter_code="360"
                  
                  foreach num of local reporter_code{
                  foreach wave of varlist periodI {
                  egen cc=group(commodity_code)
                  forvalues i=1/66{
                    di "reporter_code=360"
                    di "year=`wave'"
                    di "commodity_code=`i'"
                  capture noisily xtreg ln_tradevalues `econvars' `geogvars'  if reporter_code==`num' & `wave'==1 & cc>10 & cc<13,fe
                  estimates store fixed
                  capture noisily xtreg ln_tradevalues `econvars' `geogvars'  if reporter_code==`num' & `wave'==1 & cc>10 & cc<13,re
                  estimates store random
                  hausman fixed random,sigmamore
                   
                  }
                  }
                  }
                  (command #3)

                  In the above commands, cc is generated using
                  Code:
                   egen cc=group(commodity_code)
                  Code:
                  commodity_code 00 to 10 fall under cc=11    (item 1)
                  commodity_code 11 to 12 fall between cc=11 & cc=12 (item 2)
                  so on.

                  The above commands (command #2 & 3 ) correspond to the commondity_groups (panels) I have provided as samples (item 1 & 2).


                  The commands I have created (command #1&2) have provided me results under FEM and REM the following implausible results (see the in BETWEEN variations),

                  Code:
                  Fixed-effects (within) regression               Number of obs     =      4,622
                  Group variable: panelset                               Number of groups  =          8
                  
                  R-sq:                                                         Obs per group:
                  within  = 0.5865                                        min =        269
                  between = 0.9119                                     avg =      577.8
                  overall = 0.5909                                        max =        764
                  
                                                                               F(16,4598)        =     407.60
                  corr(u_i, Xb)  = -0.1089                        Prob > F          =     0.0000
                  
                  ------------------------------------------------------------------------------------
                  ln_tradevalues |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                  -------------------+---------------------------------------------------------------
                  ln_gdpi |          0  (omitted)
                  ln_gdpj |       -2.381353     .2459773    -9.68   0.000    -2.863586  -1.899119
                  ln_gdpjsqrd |   .0675799   .0050079    13.49   0.000      .057762      .0773978
                  Code:
                  Random-effects GLS regression                   Number of obs     =      4,622
                  Group variable: panelset                                   Number of groups  =          8
                  
                  R-sq:                                                                Obs per group:
                       within  = 0.5865                                          min =        269
                       between = 1.0000                                       avg =      577.8
                       overall = 0.5931                                          max =        764
                  
                                                                                 Wald chi2(23)     =          .
                  corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =          .
                  
                  ------------------------------------------------------------------------------------
                      ln_tradevalues |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
                  -------------------+----------------------------------------------------------------
                             ln_gdpi |       0  (omitted)
                             ln_gdpj |     -2.381353   .2459773    -9.68   0.000  -2.86346     -1.899246
                         ln_gdpjsqrd |   .0675799   .0050079    13.49   0.000     .0577646    .0773952
                  Like you can see the in Between for FEM (0.9119) and REM (1.00) look implausible.

                  Assuming in the sample data observations I have provided at the top of the page (above), if index numbers 1&2 (column 3) fall in the first group (first panel) and index number 3&4 (column 4) fall under the second group (second panel). How could I formulate my commands under the fixed effects model (FEM) and random effects model (REM) to avoid these problems?

                  How can I correct this errors? What would be the correct set up for FEM and REM?


                  I appreciate you assistance in resolving these FEM and REM command formulation problems?

                  Comment


                  • #10
                    Well, I don't find those between R2 values implausible. You only have 8 groups, and you have 6 predictors (one of which you are losing due to colinearity). So I would expect a very high between R2. Remember that the N for a between regression is the number of groups.

                    Your problem earlier in the thread was that you had so many groups that there were only singletons in each group. You've apparently gone too far in the other direction, setting up your panels so broadly that you only have 8 of them.

                    Comment


                    • #11
                      Thanks for the insight.

                      Comment


                      • #12
                        I have a couple of questions related to the above data and analysis (#1 through #10). That is I have industry/product level data that I would like to do the analysis at the country level and regional level (by aggregating the data using the loops similar to those shown above).

                        In order to aggregate the industry /product level data, what is the easiest way to aggregate using loops (as I have large data with significantly high number of products/industries)?
                        or how can I create a new country id or regional id to aggregate my data under (for instance, by summing industry level data to country or regional level data)?

                        The data is hierarchical with country id nested under product id and the product level data has cross sectional and time series dimensions, as indicated above (#3 above). The sample above (#3) represents only one country (id code 360) and I have data for multiple countries.

                        Following the loops similar to above in #9 without creating a new country or regional id has rendered many of my variables suffer multi-collinearity. Hence, they were omitted from my panel regression analysis.

                        I would like to create a new country id or regional id and replicate the product ids under it to aggregate my data under (for instance, by summing industry level data to country or regional level data), how can I accomplish these two tasks?

                        Your help is much appreciated.

                        Comment


                        • #13
                          Sounds like you want to look at -help collapse-.

                          Comment

                          Working...
                          X