57408

R squared and adjusted R squared with one predictor

Question:

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 R<sup>2</sup> and adjusted-R<sup>2</sup> values the same. These should be interchangeable if there is only one predictor in the model. What am I missing here?

Answer1:

Wikipedia gives two definitions for adjusted-R<sup>2</sup>:

<a href="https://i.stack.imgur.com/JNJVW.png" rel="nofollow"><img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/JNJVW.png" data-original="https://i.stack.imgur.com/JNJVW.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" /></a>

and

<a href="https://i.stack.imgur.com/yt83Y.png" rel="nofollow"><img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/yt83Y.png" data-original="https://i.stack.imgur.com/yt83Y.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" /></a>

I'm guessing that your assertion that R<sup>2</sup> should equal adjusted-R<sup>2</sup> is based on that first equation since when <em>p</em> is <em>1</em> the numerator on the second term is <em>0</em>. 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 <a href="http://www-bcf.usc.edu/~gareth/ISL/" rel="nofollow">Introduction to Statistical Learning</a>, will differ from R<sup>2</sup> because <em>df<sub>e</sub></em> is <em>n - p - 1</em> whereas <em>df<sub>t</sub></em> is just <em>n - 1</em> and thus there is a difference of <em>1</em> when <em>p</em> equals <em>1</em> (i.e. only one explanatory variable) but the difference should be pretty small. <a href="http://blog.minitab.com/blog/adventures-in-statistics/multiple-regession-analysis-use-adjusted-r-squared-and-predicted-r-squared-to-include-the-correct-number-of-variables" rel="nofollow">Here is a random example</a> which has a table of R<sup>2</sup> and adjusted-R<sup>2</sup> 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 R<sup>2</sup> and adjusted-R<sup>2</sup> values and see if they match.

Recommend

  • knockout Interdependent variables
  • Is *0.25 faster than / 4 in VB.NET
  • Python class for homogenous sets of objects
  • WinBUGS - Defining a discrete stepwise distribution
  • Does JavaScript run out of timeout IDs?
  • ImageView with squared pixels (without interpolation)
  • How to set the RadioButton icon style to nothing in CSS (in Flex 3)?
  • How to do linked data selections in HoloViews with Datashader + Bokeh backend
  • Replacing rownames of data frame by a sub-string
  • Help me understand this C code (*(void(*) ()) scode) ()
  • valid way to calculate angle between 2 CLLocations?
  • smart pointer array deletor
  • malloc error C++ [duplicate]
  • Subsetting DataFrame in R by duplicate values for Year by lowest value for Rating
  • Bind an ObservableCollection to Lines
  • friend class with forward class declaration does not compile
  • Matlab FFT and FFTW
  • Plotting a histogram from cellvalues
  • Replace value in unordered list (html) + JQuery
  • Calculating the occurrences of numbers in the subsets of a data.frame
  • the five top rows of the oval are erased. why?
  • Getting Coordinates of a Point in a circle
  • Content Security Policy Internet explorer error
  • C# - Why is Math.Atan(1) != anything near 45
  • Force ggplot legend to show all categories when no values are present [duplicate]
  • How to move object along the polygons
  • Java Circle-Circle Collision Detection
  • How do you open .txt file containing matrix in Matlab?
  • No projects found to import
  • Adding/Removing Lines from a JPanel
  • Filter on CALayer except for a shape which is an union of (non necessarily distinct) rectangles
  • Set matplotlib plot axis to be the dataframe column name
  • htaccess add www if not subdomain, if subdomain remove www
  • How to avoid particles glitching together in an elastic particle collision simulator?
  • Jenkins: How To Build multiple projects from a TFS repository?
  • Hits per day in Google Big Query
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Linking SubReports Without LinkChild/LinkMaster
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • How can i traverse a binary tree from right to left in java?