Announcement

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

  • How can i manual calculating R-squared for random effects?

    Hallo,

    i´m sorry for this simple question in a forum like this. But I don’t know what to do next.
    I run random effects regression and obtain the overall R-squared. Then I would like to calculate the r-squared manual.

    I know the formula for r-squared and this work for usual regress command.

    reg y x
    predict y_hat

    Then i obtain the standard deviation for y and y_hat.

    r-squared = SSE / SST = (standard deviation_ y_hat)^2/(standard deviation_y)^2

    I get exactly reported r-squared.

    But this approach doesn’t work after xtreg / xtregar command. The manual calculated r-squared is always approx.0,01 or 0,02 smaller or higher like reported r2. I know the formula for overall r-squared is corr(xitβ^,yit)2 . But I think xitβ = y_it_hat and I can use the usual r-squared formula r2= SSE/ SST.

    I am very grateful for your help.

  • #2
    I am afraid this is pretty confusing. Which of the reported R2 are you referring to? Both -xtreg- and -xtregar- produce three R2 measures--within, between, and overall. Also none is likely the same as from the OLS because these regression methods account for the effects of panels/grouping. Part of the variation are modeled at the panel level (thus the subscript t).
    Last edited by Aspen Chen; 05 Oct 2014, 23:42.

    Comment


    • #3
      Oksana:
      as Aspen notices, your question is quite vague.
      I would advice you to take a look at -help xtreg - and related entry in Stata 13.1 .pdf manual and/or any advanced econometric textbook covering panel data analysis. For Stata users, the following one is very interesting and widely covers panel data analysis: http://www.stata.com/bookstore/micro...ata/index.html.

      Kind regards,
      Carlo
      Kind regards,
      Carlo
      (StataNow 18.5)

      Comment


      • #4
        i´m sorry for my vague question.

        i try manuall to calculate overall R^2.

        - help xtreg - report only the formula corr(xitβ^,yit)2 for overall R^2. i would like to understand how stata calculate the value of OVERALL R^2.

        i found a solution of my question. insteatd of r-squared = SSE / SST = (standard deviation_ y_hat)^2/(standard deviation_y)^2 i use corr(y_hat_it, y_it)^2.
        to i get the reported overall R^2 value.

        Comment


        • #5
          suppose you have the following regression:

          xtreg y x1 x2 , re
          predict yh , xb
          corr yh y
          * Overall R2
          scalar r2 = r(rho)^2
          di r2

          Comment


          • #6
            Oksana, glad you figured it out.
            I need to correct myself--the "overall" R2 from random effect models in -xtreg- should be the same as from the OLS estimates. For example,
            Code:
            webuse nlswork,clear
            reg ln_wage grade
            xtset idcode
            xtreg ln_wage grade,re
            The manual does offer information to the original question. See page 368 (for Stata 13). I typed "yhat" to represent the notation with a hat on top.
            ...the R-squares reported do not have all the properties of the OLS R2. The ordinary properties of R2 include being equal to the squared correlation between yhat and y and being equal to the fraction of the variation in y explained by yhat, formally defined as Var(yhat)/Var(y). The identity of the definitions is from a special property of the OLS estimates...
            Then the next paragraph goes on to explain that the overall R2 from -xtreg- can be understood as the product of a weighted prediction.

            Interestingly, the respective predicted values from the -reg- and -xtreg- estimates have a perfect correlation of one. I was not aware of this property.

            Comment

            Working...
            X