# RSS of different models given true relationship between X and Y [closed]

My question is if we have three models e.g. linear regression, polynomial regression and smoothing spline, what would be the expected values of their RSS (training and test) be if the true relationship is 1) linear and 2) cubic. Let's say the data set is 1000.

• Your question is too broad and also a conclusive answer is not possible. The expected RSS (residual sum of squares) depends on a combination of the noise, the underlying function, the fitted function, and the distribution of the non-dependent parameter. I imagine that this is a hypothetical case and that you might have an underlying, more specific, problem. If that is the case could you provide the details. – Sextus Empiricus Aug 23 '17 at 2:46
• To be perfectly honest, I have a machine learning exam in a few days and this is one of the questions from the past exams. It is broad and that's all the information it is provided. The type of models, the true relationship and the dataset and based on this and theorical knowledge you have answer what would the expected values of RSS (both training and test) would be. Of course an exact number is not required but how those would compare and why. I hope that clears it up a bit for you. – R1ddler Aug 23 '17 at 18:21
• e.g. I would expect linear and polynomial to perform better than spline when the true relationship is linear and spline to perform better when cubic but I don't know how to explain and corroborate it only using the given info and how their RSS (both train and test) would compare. – R1ddler Aug 23 '17 at 18:24

## This image,

which occurs in other forms at many places (a b c d) on this website may help you to get a better intuitive understanding.

The image is a demonstration of relationship RSS of training and test data as function of the order of the fit curve and the order of the true relationship.

Your question relates to this over-/under-fitting

## training data

The linear function, polynomial function, and spline function are actually nested models. The space of all polynomial functions includes all linear functions, and the space of all spline functions contains all polynomial functions (if they are the same order).

Therefore you will always have $RSS_{linear} \geq RSS_{polynomial} \geq RSS_{spline}$ for the training data due to over-fitting. This is the blue curve going down.

## test data

The case for the test data is more difficult because it is not monotonically decreasing with increasing model complexity.

In the case of over-fitting the fitting model has more degrees of freedom than the true relationship. These degrees of freedom will reduce the RSS in the training data due to the fitting of the error terms. However these error terms will be different in the test data and therefore those extra degrees of freedom (which make the fitted function, more similar to the error terms, but also more different from the true relationship) actually decrease the accuracy of the fitted model.

## Variations in the effect of over-/under-fitting

Notice the following effects in the images.

• If there are more points (from top to bottom 40, 160, 640 points) than the over-fitting will be less strong
• The decrease of RSS for training data (blue curves) is less strong
• The increase of RSS for test data (red curves) is less strong
• There is a certain point at which the RSS for test data is at a minimum. Before this point you have under-fitting, past this point you have over-fitting. This point is where the true relationship and fitted curve are most resembling (note: not entirely, in the case of the image the 3th order actually performs better than the 4th order in modeling the 4th order true relationship. This may be because the additional fourth order term might be correlating too strongly with the error terms in the training data and not result in a better fit of the test data)
• Also note that the test RSS is always higher than the training RSS. The linear curve will also over-fit the linear relationship (the error terms in the training data may have some linear relationship, which is different from the true relationship, causing the fitted model to be not exactly the same as the true relationship, and while the fitted model optimizes the RSS in the training data, this optimization is detrimental in the test data)

## case of linear and cubic relationships

So in the linear true relationship

• the linear function is doing just fine.
• the polynomial function is over-fitting and the spline even more.

And with the cubic true relationship

• the linear function is underfitting
• the polynomial is just fine for order 3 (and underfitting for order 2 and overfitting for order >3, so the question is a bit ambiguous)
• the spline is over-fitting (Although the comparison is difficult. For instance a spline of order 1 or 2 might do reasonable in fitting a cubic relationship. In the above six images the spline also does not really fit on the x-axis since the spline is not just a function varying in order but also the number of pieces)

## sum of squares of residuals in relation to sum of squares of errors

Without over-/under-fitting the RSS will be close to the sum of squares of the error terms. For the training data it will be lower (because of slight fitting of the error terms that is always present) and for the testing data it will be higher (because of the fit not matching exactly the true relationship, due to these error terms in the test data).

With over-fitting the RSS will be lower for training data but higher for test data.

With under-fitting the RSS will be higher for both training data and test data.

## problematic question

In the case of your specific question it is difficult to give exact answer because of the ambiguity.

• The polynomial function can have different orders.
• The spline is not defined exactly
• it is difficult to say, in the cubic relationship case, if the under-fitting of the linear function is worse than the over-fitting of the spline
• the cubic function might be be very close to a linear function if the coefficient for the higher order terms are small.
• as stated above: In theory, a first order function might be better at fitting a third order true relationship than a polynomial function of order 2 or 3. This has to do with the error terms correlating with the 2nd and 3th order terms and possibly creating a larger deviation from the true relationship rather than a better approximation of the true relationship. The reduction in degrees of freedom reduces the quality of the fit and may be worse than what the resemblance of the fitting function to the the true relationship can recover.

The answer to that question explains very nicely the change of RSS in training data as function of polynomial order.

(the title in that question also mentions test data aside from training data, but that test data part does not occur in the text of the question and answer, which is more about the confusion between RSS and RSE)

Note that over-fitting reduces RSS in training data, but increases RSS in test data.

• Thank you so much for your answer. This definitely clears things up a bit for me. The polynomial for the question is of fourth degree Y = beta0 + beta1X + beta22X2 + beta3X3 + beta4X4 + error_term. – R1ddler Aug 24 '17 at 14:52
• For the smoothing spline it's only mentioned that it's more flexible (complex) than the other two. So if I understood correctly for the RSS of the training data when the linear relationship is true, RSSlinear >= RSSpoly4 >= RSSsmoothingsplines. Is the same true for the cubic relationship for the training RSS? Or is it hard to say if the underfit of the linear model on the true cubic will be worse than the overfit of 4th degree poly and smooth spline. For test data I assume for the true linear that the linear regression will have smallest RSS while the RSS of the poly and spline will increase. – R1ddler Aug 24 '17 at 15:03
• "Or is it hard to say if the underfit of the linear model on the true cubic will be worse than the overfit of 4th degree poly and smooth spline. " In the case of the training data the more complex function will always do better. Both for the linear relationship and the cubic relationship, or any other relationship. The problem of over-fitting (the model adjusting to the error terms in addition to the model) is not noticed in the training RSS (whose error terms are fitted) but in the test RSS (whose error terms are different and unlikely to correspond to the overfitted parameterization). – Sextus Empiricus Aug 24 '17 at 16:07