R squared and adjusted R squared with one predictor

梦想与她 提交于 2019-12-24 15:43:02

问题


Using the following to estimate the coefficient of determination in MATLAB:

load hospital
y = hospital.BloodPressure(:,1);
X = double(hospital(:,2:5));
X2 = X(:,3);
mdl = fitlm(X2,y);

Estimated Coefficients:
                   Estimate       SE       tStat       pValue  
                   ________    ________    ______    __________

    (Intercept)      116.72      3.9389    29.633    1.0298e-50
    x1             0.039357    0.025208    1.5613       0.12168


Number of observations: 100, Error degrees of freedom: 98
Root Mean Squared Error: 6.66
R-squared: 0.0243,  Adjusted R-Squared 0.0143
F-statistic vs. constant model: 2.44, p-value = 0.122

If I'm only using one predictor variable in the linear model, why aren't the R2 and adjusted-R2 values the same. These should be interchangeable if there is only one predictor in the model. What am I missing here?


回答1:


Wikipedia gives two definitions for adjusted-R2:

and

I'm guessing that your assertion that R2 should equal adjusted-R2 is based on that first equation since when p is 1 the numerator on the second term is 0. Now I couldn't find a reference for this (and disappointingly there are no citations in this section of the wiki article) but I'm fairly confident that the first equation is actually an approximation.

The second equation, which aside from the notation also matches equation 6.4 on page 212 of Introduction to Statistical Learning, will differ from R2 because dfe is n - p - 1 whereas dft is just n - 1 and thus there is a difference of 1 when p equals 1 (i.e. only one explanatory variable) but the difference should be pretty small. Here is a random example which has a table of R2 and adjusted-R2 showing the difference even when the number of variables is 1.

Your difference is pretty large though. I suggest you look at you residual sum of squares and total sum of squares to see if you can calculate your own R2 and adjusted-R2 values and see if they match.



来源:https://stackoverflow.com/questions/37001280/r-squared-and-adjusted-r-squared-with-one-predictor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!