# Negative adjusted coefficients of determination - why?

I am trying to fit a polynomial function to some multi-dimensional data. However, I am getting a negative $R_{adj}^2$ as you can see:

datat = {{2.0000, 35.229, 2.61922, 1.26667, 5.9160*10^6, 14217.,
0.04422}, {2.0000, 40.522, 2.70379, 9.76264, 2.6300*10^6, 5202.0,
0.039375}, {1.0000, 24.3, 2.62143, 5.0000, 3.4141*10^6, 8163.0,
0.042542}, {2.0000, 48.87, 2.66604, 15.000, 4.8240*10^6, 10408.,
0.040983}, {2.0000, 41.59, 2.67677, 2.47553, 2.3944*10^6, 5040.0,
0.042063}, {2.0000, 39.629, 2.99468, 1.18333, 5.8163*10^6, 5888.0,
0.039648}, {2.0000, 39.618, 2.6657, 1.8, 2.3768*10^6, 5132.0,
0.038273}, {2.0000, 42.924, 2.68517, 1.2557, 2.4082*10^6, 4972.0,
0.041902}, {1.0000, 32.8, 2.48408, 5.0000, 1.8193*10^7, 59681.,
0.041759}};
lmf = LinearModelFit[datat, {1}~Join~{o, g, p, d, a, t}, {o, g, p, d, a, t}];
(*out: -0.511164*)


By definition, in 2-dimensional space an Adjusted $R^2<0$ indicates that the predicted line is worse at fitting the data than an horizontal line (if I'm not mistaken). In this 6-dimensional case, I believe a negative $R^2_{adj}$ indicates that the hyperplane is worse at describing the data than a random hyperplane.

So, my questions are:

1. How is this possible? I would expect that this could happen if I didn't have a constant term in the fitting function (indicated by the {1} term in lmf);
2. Are there other algorithms that I can use instead of the default regression one that maybe could solve this problem? (i.e. to get $R^2_{adj} = 0$ as lowest coefficient of determination)

Thanks

• ehm, now that I look at both questions at the bottom, I am wondering if the title is the most appropriate
– Sos
Commented Oct 5, 2015 at 17:45
• Are you really trying to fit "data to a model (polynomial)" - an intriguing endeavor? I do not quite understand, why you joining the {1} to the list of functions; it does not change a thing and by definition an intercept is automatically added (e.g. beta0)?
– gwr
Commented Oct 5, 2015 at 18:06
• @gwr - I meant the other way around. I apologize and will correct that right away. Indeed, I notice that the documentation adds an intercept by default, but having that {1} changes nothing. The main issue remains
– Sos
Commented Oct 5, 2015 at 18:10
• Adjusted $R^2$ might be negative if there are terms in your model that do not help to predict the response, as this page about goodness of fit tells us. If I look at the proposed linear model equation, then $a$ and $t$ have coefficients of approximately zero.
– gwr
Commented Oct 5, 2015 at 18:18
• And fitting a model with 8 parameters (1 intercept, 6 covariates, and a variance) with 9 data points is, well, kinda silly.
– JimB
Commented Oct 5, 2015 at 23:21

The formula used by Mathematica is $$R_{adj}^2={1-(1-R^2){{n-1}\over{n-p-1}}}$$ where $n$ is the sample size and $p$ is the number of parameters (excluding the intercept and assume for this example we are fitting an intercept). This means that $R_{adj}^2$ will be negative whenever $R^2<p/(n-1)$. So as the ratio of the number of parameters relative to the sample size gets large, one will need larger and larger values of $R^2$ to result in non-negative values of $R_{adj}^2$.
I understand from your comment above that you provided an example with a small sample size to show or question that one can obtain negative values. However, it is the use of a small sample size relative to the number of parameters to be fit that results in such extreme negative values of $R_{adj}^2$.
(1) By definition $R_{adj}^2$ will be negative whenever $R^2<p/(n-1)$ (when there is an intercept in the model).
(2) Negative $R_{adj}^2$ values are not a problem. Overfitting is. Further, one should consider looking less at $R^2$’s and more at residual plots and the root mean square error to judge the quality of a fit.