Announcement

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

  • r-square decreased when adding id fixed effect on xtreg panel regression

    I have three problems when fitting panel regression model with fixed effect using xtreg,fe

    first problem
    I fittted two models.
    first model includes year fixed effect and region fixed effect and id fixed effect.
    second model includes year fixed effect, region fixed effect.
    the problem is, the model that I added id fixed effect has low R-sq. I thought when I add more variable (and also fixed effect), r-sq increases.
    Am I right? or the number of fixed effect is not associated with value of r-square?
    I am interested in the relationship between Y(logfood) and uet, pet. the other variables are added as the control variables.
    here is the output
    xtset pid year, yearly

    first model
    xtreg logfood uet2_lam1_0329 pet1_lam1_0329 iliquid_w_i liquid_w_i loginc age cur_empl size sex edu maritial i.region i.year ,fe
    note: sex omitted because of collinearity
    note: 2017.year omitted because of collinearity

    Fixed-effects (within) regression Number of obs = 18265
    Group variable: pid Number of groups = 3575

    R-sq: within = 0.1340 Obs per group: min = 1
    between = 0.0648 avg = 5.1
    overall = 0.0823 max = 15

    F(39,14651) = 58.12
    corr(u_i, Xb) = -0.2528 Prob > F = 0.0000

    --------------------------------------------------------------------------------
    logfood | Coef. Std. Err. t P>|t| [95% Conf. Interval]
    ---------------+----------------------------------------------------------------
    uet2_lam1_0329 | -5.331916 2.165693 -2.46 0.014 -9.576947 -1.086884
    pet1_lam1_0329 | -.0555771 .0240872 -2.31 0.021 -.102791 -.0083632

    Second model
    xtreg logfood uet2_lam1_0329 pet1_lam1_0329 iliquid_w_i liquid_w_i loginc age cur_empl size sex edu maritial i.region ,fe i(year)
    warning: existing panel variable is not year

    Fixed-effects (within) regression Number of obs = 18265
    Group variable: year Number of groups = 15

    R-sq: within = 0.4786 Obs per group: min = 868
    between = 0.1105 avg = 1217.7
    overall = 0.4698 max = 1421

    F(27,18223) = 619.55
    corr(u_i, Xb) = 0.0048 Prob > F = 0.0000

    --------------------------------------------------------------------------------
    logfood | Coef. Std. Err. t P>|t| [95% Conf. Interval]
    ---------------+----------------------------------------------------------------
    uet2_lam1_0329 | -6.87497 1.522391 -4.52 0.000 -9.859 -3.890939
    pet1_lam1_0329 | -.0526164 .0195237 -2.69 0.007 -.0908847 -.014348



    Second problem
    when I report the value of R-square on my paper. which r-square do I have to use?
    I am interested in the relationship between Y(logfood) and uet, pet. the other variables are added as the control variables.
    what is the meaning and value of r-sq on panel regression?
    and if I want to compare r-square with pooled ols r-square, How can I do this?


    Third problem
    When I fitted the same model on the first problem, I want to cluster standard deviation by pid on both models.
    I operated following codes. the problem is that I cannot cluster second model by pid using xtreg. because panels are not nested.
    So I use reg command, clustering by pid and I get same coefficients. but I cannot get same kinds of r-square that xtreg command reports.
    Is there any way to report consistent r-square values on reg and xtreg?

    first model clustering by pid
    . xtreg logfood uet2_lam1_0329 pet1_lam1_0329 iliquid_w_i liquid_w_i loginc age cur_empl size sex edu maritial i.region i.year ,fe cluster
    > (pid)

    note: sex omitted because of collinearity
    note: 2017.year omitted because of collinearity

    Fixed-effects (within) regression Number of obs = 18265
    Group variable: pid Number of groups = 3575

    R-sq: within = 0.1340 Obs per group: min = 1
    between = 0.0648 avg = 5.1
    overall = 0.0823 max = 15

    F(38,3574) = .
    corr(u_i, Xb) = -0.2528 Prob > F = .

    (Std. Err. adjusted for 3575 clusters in pid)
    --------------------------------------------------------------------------------
    | Robust
    logfood | Coef. Std. Err. t P>|t| [95% Conf. Interval]
    ---------------+----------------------------------------------------------------
    uet2_lam1_0329 | -5.331916 2.544247 -2.10 0.036 -10.32024 -.3435932
    pet1_lam1_0329 | -.0555771 .0298144 -1.86 0.062 -.114032 .0028778


    Second model clustering by pid using xtreg
    . xtreg logfood uet2_lam1_0329 pet1_lam1_0329 iliquid_w_i liquid_w_i loginc age cur_empl size sex edu maritial i.region ,fe i(year) cluste
    > r(pid)
    warning: existing panel variable is not year
    panels are not nested within clusters


    Second model clustering by pid using reg
    xi : reg logcon uet2_lam1_0329 pet1_lam1_0329 iliquid_w_i liquid_w_i loginc age cur_empl size sex edu maritial i.year i.region , vce(cl p
    > id)
    i.year _Iyear_1998-2018 (naturally coded; _Iyear_1998 omitted)
    i.region _Iregion_1-19 (naturally coded; _Iregion_1 omitted)
    note: _Iyear_1999 omitted because of collinearity
    note: _Iyear_2000 omitted because of collinearity
    note: _Iyear_2001 omitted because of collinearity
    note: _Iyear_2002 omitted because of collinearity
    note: _Iyear_2003 omitted because of collinearity
    note: _Iyear_2018 omitted because of collinearity

    Linear regression Number of obs = 18292
    F( 40, 3578) = .
    Prob > F = .
    R-squared = 0.7768
    Root MSE = .35504

    (Std. Err. adjusted for 3579 clusters in pid)
    --------------------------------------------------------------------------------
    | Robust
    logcon | Coef. Std. Err. t P>|t| [95% Conf. Interval]
    ---------------+----------------------------------------------------------------
    uet2_lam1_0329 | -6.387408 1.901937 -3.36 0.001 -10.1164 -2.658419
    pet1_lam1_0329 | -.1468916 .019314 -7.61 0.000 -.1847591 -.109024
    Last edited by KYUTAE KIM; 03 Apr 2020, 03:56.

  • #2
    Kyutae:
    welcome to this forum.
    Your second model is simply wrong.
    You cannot -xtset- that way. See -xtset- entry in Stata .pdf manual:
    Code:
    xtset panelid year
    Last edited by Carlo Lazzaro; 03 Apr 2020, 04:27.
    Kind regards,
    Carlo
    (Stata 18.0 SE)

    Comment


    • #3
      On the issue of a declining R-squared in xtreg, fe, see #9 of the following link:
      https://www.statalist.org/forums/for...added-to-model

      EDIT: Looking again at #1, Carlo Lazzaro points out the root of the problem. The overall R-squared can decline with added dummies as shown in the link, but this can never happen with the within R-squared.
      Last edited by Andrew Musau; 03 Apr 2020, 04:41.

      Comment

      Working...
      X