Announcement

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

  • Panel Data

    Greetings,


    I have panel data with 7 or 8 years (depending on which variables are included) on the market share of cooperatives for 5 classes of agricultural commodities. Theory holds that this should be explained by the share of farms that are not family farms and the combined effects (i.e., interaction) of uncertainty and asset specificity. For asset specificity, I have a time invariant measure.

    I've been using xtreg but recently read that xtregar may be more appropriate for T>N (but is my T enough greater for it to matter?) ...


    Using xtreg, if I include only the interaction term but not its two underlying variables, then the Hausman test should be comparing FE and RE for otherwise identically specified models, in which case its insignificant p-values favor RE (also Breusch-Pagan Lagrangian multiplier test -xttest0- returns significant p-values favoring RE over pooled OLS).

    However, if I include the two interacted terms individually, along with their interaction, of course the time invariant measure of asset specificity drops out of fixed effect models, so I wondered if the Hausman test then fairly compares apples to apples or should I just go with RE, given the time invariant nature of a focal explanatory variable?

    (If needed, I can share code and results for the above but trying not to overwhelm.) No matter what model I consider, -testparm i.year- indicates that I do not need to include time dummies.


    I also considered the constant random effects model. I had to multiply my measure of Physical asset specificity by 100 and round up to be an integer (I named Pround) for this model while retaining variability. The significantly negative coefficients for two of the middle values of Pround seem to reflect that it's lowest value is a bit higher than one would expect (graphically the relationship looks nonlinear, so maybe log it).

    Also, I imagine the model doesn't know that UxPround is composed of the two underlying variables (I know that is problematic for inferring marginal effects in binary logit/probit models, but perhaps not an issue here).

    . xtreg coop_share_100 UxPround U_100 i.Pround nonfamily_share_100 , cre i(id)
    note: UxPround omitted from xt_means because of collinearity.
    note: U_100 omitted from xt_means because of collinearity.
    note: 263b.Pround omitted from xt_means because of collinearity.
    note: 370.Pround omitted from xt_means because of collinearity.
    note: 413.Pround omitted from xt_means because of collinearity.
    note: 452.Pround omitted from xt_means because of collinearity.
    note: 515.Pround omitted from xt_means because of collinearity.
    note: nonfamily_share_100 omitted from xt_means because of collinearity.

    Correlated random-effects regression Number of obs = 40
    Group variable: id Number of groups = 5

    R-squared: Obs per group:
    Within = 0.2283 min = 8
    Between = 1.0000 avg = 8.0
    Overall = 0.9729 max = 8

    Wald chi2(7) = 1149.56
    corr(xit_vars*b, xt_means*γ) = -0.5337 Prob > chi2 = 0.0000

    -------------------------------------------------------------------------------------
    coop_share_100 | Coefficient Std. err. z P>|z| [95% conf. interval]
    --------------------+----------------------------------------------------------------
    xit_vars |
    UxPround | -.0002322 .0023542 -0.10 0.921 -.0048464 .004382
    U_100 | .5960452 .8970022 0.66 0.506 -1.162047 2.354137
    |
    Pround |
    370 | 1.549425 4.532224 0.34 0.732 -7.33357 10.43242
    413 | -25.38673 5.493122 -4.62 0.000 -36.15305 -14.62041
    452 | -26.24007 8.810041 -2.98 0.003 -43.50743 -8.972702
    515 | 49.32627 6.788457 7.27 0.000 36.02114 62.6314
    |
    nonfamily_share_100 | .0076023 .23421 0.03 0.974 -.4514409 .4666454
    _cons | 31.50043 5.578254 5.65 0.000 20.56725 42.4336
    --------------------+----------------------------------------------------------------
    xt_means |
    UxPround | 0 (omitted)
    U_100 | 0 (omitted)
    |
    Pround |
    370 | 0 (omitted)
    413 | 0 (omitted)
    452 | 0 (omitted)
    515 | 0 (omitted)
    |
    nonfamily_share_100 | 0 (omitted)
    --------------------+----------------------------------------------------------------
    sigma_u | 0
    sigma_e | 4.7544057
    rho | 0 (fraction of variance due to u_i)
    -------------------------------------------------------------------------------------
    Mundlak test (xt_means = 0): chi2(0) = . Prob > chi2 = .




    In all of this (except apparently xtregar), there is the question of whether to use vce(cluster id) for robust standard errors. Is there an appropriate test, particularly after RE or am I left to save and plot residuals (and how to organize or what am I looking for in such a graph, given the observations vary over N and T)?

    Thanks in advance (seems like there's a lot of questions here)!

    Jason

  • #2
    Jason:
    with 40 obs I would switch to OLS, taking not for granted to be successful in finding something more interesting than what I get with -summarize-.
    Last edited by Carlo Lazzaro; 13 Dec 2025, 01:22.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Carlo,

      Thanks for your response, but I might be confused. Are you advising to run pooled OLS despite the Breusch-Pagan Lagrangian multiplier test -xttest0- returning significant p-values favoring RE over pooled OLS? Are you just referring to the -summarize- command in regard to just summary statistics or something else (not seeing it as a post-estimation command)?

      Sorry for my confusion. I guess if I had just the time invariant variable without the theoretical need to interact it, then the correlated random effects model would seem to make sense.

      Regardless, I still need to determine whether to use robust/clustered standard errors or classical ones. I'm familiar with graphing residuals in time series analysis but not sure how that works in a panel with the added N dimension, so was hoping there is a statistical test but am not finding one.

      Jason

      Comment


      • #4
        Jason:
        the main issue here is that with 40 observations (N=5*T=8) any statistical procedure is difficult to support.
        If you take a look at your Between and Overall values (near 1), the overfitting chime starts ringing.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Carlo,

          Between R-square isn't as high in standard RE, but still pretty high, as shown below. If it would be better, maybe I should just look at a few years numerous years apart (T=3 or 5?). The data was collected consecutively for several years with little changes and then stopped in 2002 with one more observation reported in 2022.


          . xtreg coop_share UxPhy coef_var_applecrancherry Phy nonfamily_share , re i(id) vce(cluster id)

          Random-effects GLS regression Number of obs = 40
          Group variable: id Number of groups = 5

          R-squared: Obs per group:
          Within = 0.0235 min = 8
          Between = 0.7962 avg = 8.0
          Overall = 0.6355 max = 8

          Wald chi2(4) = 76.29
          corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000

          (Std. err. adjusted for 5 clusters in id)
          ------------------------------------------------------------------------------------------
          | Robust
          coop_share | Coefficient std. err. z P>|z| [95% conf. interval]
          -------------------------+----------------------------------------------------------------
          UxPhy | -107.3532 99.28163 -1.08 0.280 -301.9416 87.23522
          coef_var_applecrancherry | 4.85866 4.538085 1.07 0.284 -4.035824 13.75314
          Phy | 34.27271 19.26588 1.78 0.075 -3.487713 72.03314
          nonfamily_share | -1.89544 .5426161 -3.49 0.000 -2.958948 -.831932
          _cons | -.8451106 .8909308 -0.95 0.343 -2.591303 .9010817
          -------------------------+----------------------------------------------------------------
          sigma_u | 0
          sigma_e | .04754393
          rho | 0 (fraction of variance due to u_i)
          ------------------------------------------------------------------------------------------




          Thanks,


          Jason

          Comment


          • #6
            Jason:
            1) Stata did not return -sigma_u-: what is the panelwise effect here?
            2) you cannot cluster below N0>30 observations (Cameron_Miller_JHR_2015_February.pdf).
            3) you're asking too much out of 40 observations.
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment


            • #7
              Carlo,

              I appreciate you patience with me and my first attempt at panel data work. At first I thought maybe the issue is too many T (8) relative to N (5), but are you saying I need more observations altogether?

              I can't change N easily but I can increase T to 11 by dropping the nonfamily_share variable to bring total observations up to 55 (N=5xT=11).

              Interesting trade-off here, as nonfamily_share is driving most of the Between Rsquare and the other variables contributing to Within R square (or maybe that's reflecting the different T covered by the two regressions).

              . xtreg coop_share UxPhy coef_var_applecrancherry Phy , re i(id)

              Random-effects GLS regression Number of obs = 55
              Group variable: id Number of groups = 5

              R-squared: Obs per group:
              Within = 0.2127 min = 11
              Between = 0.0479 avg = 11.0
              Overall = 0.0514 max = 11

              Wald chi2(3) = 10.99
              corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0118

              ------------------------------------------------------------------------------------------
              coop_share | Coefficient Std. err. z P>|z| [95% conf. interval]
              -------------------------+----------------------------------------------------------------
              UxPhy | -8.921904 17.57863 -0.51 0.612 -43.37539 25.53158
              coef_var_applecrancherry | .7560373 .6677304 1.13 0.258 -.5526901 2.064765
              Phy | 12.08075 9.101142 1.33 0.184 -5.757155 29.91866
              _cons | -.1541115 .3732267 -0.41 0.680 -.8856224 .5773994
              -------------------------+----------------------------------------------------------------
              sigma_u | .1510247
              sigma_e | .04090348
              rho | .93165897 (fraction of variance due to u_i)
              ------------------------------------------------------------------------------------------

              . xtreg coop_share nonfamily_share , re i(id)

              Random-effects GLS regression Number of obs = 40
              Group variable: id Number of groups = 5

              R-squared: Obs per group:
              Within = 0.0033 min = 8
              Between = 0.2932 avg = 8.0
              Overall = 0.2402 max = 8

              Wald chi2(1) = 0.02
              corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.8851

              ---------------------------------------------------------------------------------
              coop_share | Coefficient Std. err. z P>|z| [95% conf. interval]
              ----------------+----------------------------------------------------------------
              nonfamily_share | .0337828 .2337239 0.14 0.885 -.4243078 .4918733
              _cons | .3845207 .1271586 3.02 0.002 .1352945 .6337469
              ----------------+----------------------------------------------------------------
              sigma_u | .27486534
              sigma_e | .05242024
              rho | .96490521 (fraction of variance due to u_i)
              ---------------------------------------------------------------------------------



              Alternatively, given that the physical asset specificity measure is time invariant and would drop out of a fixed effects model, perhaps considering just the interaction of this variable with uncertainty (and including the nonfamily farm variable) could be more tractable? I get sigma_u and sigma_e and don't overfit (between and overall R-square compared to within). Breusch-Pagan test favors RE over pooled OLS, and Hausman test favors RE to FE. Here, I don't use a cluster or robust option (which I believe are equivalent here) for standard errors. But how do I know I can trust the classical standard errors?


              . xtreg coop_share UxPhy nonfamily_share , fe i(id)

              Fixed-effects (within) regression Number of obs = 40
              Group variable: id Number of groups = 5

              R-squared: Obs per group:
              Within = 0.2177 min = 8
              Between = 0.2785 avg = 8.0
              Overall = 0.1446 max = 8

              F(2, 33) = 4.59
              corr(u_i, Xb) = -0.5077 Prob > F = 0.0174

              ---------------------------------------------------------------------------------
              coop_share | Coefficient Std. err. t P>|t| [95% conf. interval]
              ----------------+----------------------------------------------------------------
              UxPhy | 13.05236 4.340005 3.01 0.005 4.222557 21.88217
              nonfamily_share | -.048607 .2164306 -0.22 0.824 -.4889383 .3917244
              _cons | .3189659 .0340245 9.37 0.000 .2497424 .3881893
              ----------------+----------------------------------------------------------------
              sigma_u | .30512793
              sigma_e | .04713922
              rho | .97668919 (fraction of variance due to u_i)
              ---------------------------------------------------------------------------------
              F test that all u_i=0: F(4, 33) = 219.43 Prob > F = 0.0000

              .
              . estimate store fix_UxPhy1

              .
              . xtreg coop_share UxPhy nonfamily_share , re i(id)

              Random-effects GLS regression Number of obs = 40
              Group variable: id Number of groups = 5

              R-squared: Obs per group:
              Within = 0.2173 min = 8
              Between = 0.2722 avg = 8.0
              Overall = 0.1330 max = 8

              Wald chi2(2) = 8.93
              corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0115

              ---------------------------------------------------------------------------------
              coop_share | Coefficient Std. err. z P>|z| [95% conf. interval]
              ----------------+----------------------------------------------------------------
              UxPhy | 12.77317 4.290641 2.98 0.003 4.36367 21.18267
              nonfamily_share | -.0749038 .213016 -0.35 0.725 -.4924074 .3425999
              _cons | .3238809 .1519283 2.13 0.033 .0261068 .621655
              ----------------+----------------------------------------------------------------
              sigma_u | .33460284
              sigma_e | .04713922
              rho | .98053877 (fraction of variance due to u_i)
              ---------------------------------------------------------------------------------

              .
              . estimate store rand_UxPhy1

              .
              . hausman fix_UxPhy1 rand_UxPhy1

              ---- Coefficients ----
              | (b) (B) (b-B) sqrt(diag(V_b-V_B))
              | fix_UxPhy1 rand_UxPhy1 Difference Std. err.
              -------------+----------------------------------------------------------------
              UxPhy | 13.05236 12.77317 .2791922 .6527195
              nonfamily_~e | -.048607 -.0749038 .0262968 .0382934
              ------------------------------------------------------------------------------
              b = Consistent under H0 and Ha; obtained from xtreg.
              B = Inconsistent under Ha, efficient under H0; obtained from xtreg.

              Test of H0: Difference in coefficients not systematic

              chi2(2) = (b-B)'[(V_b-V_B)^(-1)](b-B)
              = 0.62
              Prob > chi2 = 0.7323


              . xttest0

              Breusch and Pagan Lagrangian multiplier test for random effects

              coop_share[id,t] = Xb + u[id] + e[id,t]

              Estimated results:
              | Var SD = sqrt(Var)
              ---------+-----------------------------
              coop_sh~e | .068483 .2616926
              e | .0022221 .0471392
              u | .1119591 .3346028

              Test: Var(u) = 0
              chibar2(01) = 110.21
              Prob > chibar2 = 0.0000




              Thanks again for sharing your insights.


              Jason

              Comment


              • #8
                Given my N is too small to cluster, perhaps can use the Kenward-Rogers degrees of freedom adjustment. Though this doesn't return the within, between, and overall R-square values, as I understand it, I can use the ones from an equivalently specified xtreg RE (GLS) model output, since it is a restricted or special case version of mixed.

                mixed coop_share c.ln_uncertainty##c.site_original || id:, reml dfmethod(kroger)

                Performing EM optimization ...

                Performing gradient-based optimization:
                Iteration 0: Log restricted-likelihood = 69.00018
                Iteration 1: Log restricted-likelihood = 69.00018

                Computing standard errors ...

                Computing degrees of freedom ...

                Mixed-effects REML regression Number of obs = 50
                Group variable: id Number of groups = 5
                Obs per group:
                min = 10
                avg = 10.0
                max = 10
                DF method: Kenward–Roger DF: min = 3.45
                avg = 23.56
                max = 43.73
                F(3, 11.16) = 3.96
                Log restricted-likelihood = 69.00018 Prob > F = 0.0381

                --------------------------------------------------------------------------------------------------
                coop_share | Coefficient Std. err. t P>|t| [95% conf. interval]
                ---------------------------------+----------------------------------------------------------------
                ln_uncertainty | .4255056 .1391399 3.06 0.004 .1450131 .7059982
                site_original | -.0755123 .2271101 -0.33 0.759 -.7454837 .5944591
                |
                c.ln_uncertainty#c.site_original | -.0900438 .0324006 -2.78 0.008 -.1553545 -.0247331
                |
                _cons | .7904537 .9990838 0.79 0.480 -2.16504 3.745947
                --------------------------------------------------------------------------------------------------

                ------------------------------------------------------------------------------
                Random-effects parameters | Estimate Std. err. [95% conf. interval]
                -----------------------------+------------------------------------------------
                id: Identity |
                var(_cons) | .0865926 .0715146 .0171592 .4369841
                -----------------------------+------------------------------------------------
                var(Residual) | .0015973 .0003446 .0010465 .002438
                ------------------------------------------------------------------------------
                LR test vs. linear model: chibar2(01) = 102.42 Prob >= chibar2 = 0.0000


                Comment


                • #9
                  Jason:
                  It depends on what you're doing panel data regression for.
                  If it is a personal analysis on a given dataset, there's nothing wrong with your approach, but a very limited sample size.
                  Uf you plan to submit your paper to a technical journal, the limited sample size is clearly an issue, unless you're investigating a rare occurrence (say, a rare disease).
                  In addition:
                  1) reducing the number of regressors to obtain p-value<0.05 is a risky approach: your regression might be misspecified (see -linktest- procedure, to be replicated by hand after -xtreg-) and/or suffer from endogeneity (if you do not include all the preedictors of your data generating process in the right-hand side of your regression equation);
                  2) take a look at the difference between the default and cluster-robust standard errors to get a clue about which one is better in your case.
                  Kind regards,
                  Carlo
                  (Stata 19.0)

                  Comment


                  • #10
                    Carlo:

                    Journal article would be nice but could also use to teach students with freely available USDA government data in our research context.

                    If I retain the nonfamily farm variable that I dropped in prior output and log that variable, implications for the other variables don't change much (p-value=0.011 for interaction term instead of significant at 1%) and the LNnonfamily variable is significant but only at 10%. The linktest doesn't like dropping the variable, which makes sense.

                    Besides the small sample, the aggregate nature of the data (commodities like grain instead of grain firms, where I could include firm age or firm size, etc.) is problematic. Also, kind of hoping I can use this exploration to suggest that there appears to be something to this, and it warrants further data collection.

                    . mixed coop_share c.ln_uncertainty##c.Site LNnonfamily if year<2022 || id:, reml dfmethod(kroger)

                    Performing EM optimization ...

                    Performing gradient-based optimization:
                    Iteration 0: Log restricted-likelihood = 48.415437
                    Iteration 1: Log restricted-likelihood = 48.415437

                    Computing standard errors ...

                    Computing degrees of freedom ...

                    Mixed-effects REML regression Number of obs = 35
                    Group variable: id Number of groups = 5
                    Obs per group:
                    min = 7
                    avg = 7.0
                    max = 7
                    DF method: Kenward–Roger DF: min = 4.05
                    avg = 18.11
                    max = 27.47
                    F(4, 13.39) = 3.77
                    Log restricted-likelihood = 48.415437 Prob > F = 0.0291

                    -----------------------------------------------------------------------------------------
                    coop_share | Coefficient Std. err. t P>|t| [95% conf. interval]
                    ------------------------+----------------------------------------------------------------
                    ln_uncertainty | .5922423 .1905855 3.11 0.004 .2014501 .9830345
                    Site | -7.883004 22.12052 -0.36 0.739 -68.99361 53.2276
                    |
                    c.ln_uncertainty#c.Site | -11.65995 4.290097 -2.72 0.011 -20.45549 -2.864413
                    |
                    LNnonfamily | -.0518807 .0263914 -1.97 0.060 -.1059883 .0022269
                    _cons | .7762268 .9818619 0.79 0.472 -1.905466 3.457919
                    -----------------------------------------------------------------------------------------

                    ------------------------------------------------------------------------------
                    Random-effects parameters | Estimate Std. err. [95% conf. interval]
                    -----------------------------+------------------------------------------------
                    id: Identity |
                    var(_cons) | .0754271 .0629025 .0147118 .3867119
                    -----------------------------+------------------------------------------------
                    var(Residual) | .0018554 .0005054 .0010878 .0031646
                    ------------------------------------------------------------------------------
                    LR test vs. linear model: chibar2(01) = 46.22 Prob >= chibar2 = 0.0000



                    Thanks again,

                    Jason

                    Comment


                    • #11
                      Jason:
                      again, it depends on the aim of your research.
                      That said, I share your "more research is needed" approach.
                      Kind regards,
                      Carlo
                      (Stata 19.0)

                      Comment

                      Working...
                      X