# Residuals in a Machine Learning with forecasting

I'm affraid to confuse something. Here's my assumption :

I have a timeseries that I split in 2 parts Learning data and test data.

A residual in forecasting is the difference between an observed value and its forecast based on other observations: ei=yi−y^iei=yi−y^i.

I want to see how good my model is so I want t know the residuals.

But which data are my observations ? For me, it's my learning data + my test data. Because i had prediction on all my data. (On the learning data and the most important on my test data)

EDIT : So i'm calcutating the residuals on all my data.

EDIT 2 : Paper

Am I right ?

I see two steps

1 -- MODEL SELECTION

Here we use a train and a test error to select a model. In this contest, model refers to a the mathematical formulation of a solution (a function $\hat f (x, \theta)$) rather than a specific instance of a model where every parameter ($\theta$) has been set. Or, in other words, the performance of a method of producing a model, not of the model itself (see)

In this step. You will deal with test and train error. That is residuals on the test and train data. The analysis should take into account and discriminate between test and train. You can read about the bias/variance tradeoff here.

I would also recommend

In a nutshell (source): 2 -- MODEL FITTING

In this phase, after having selected a model, we fit it to the data. In case of a simple linear regression, we can find the $\theta$ that minimizes the cost function.

Here we make use of the whole dataset. We make use of the whole dataset because we have already analyzed how a model generalizes and the risk of overfitting in step 1. Now it is time to estimate $\theta$ and the more data we have, the better it is.

I believe that it is in this context that it is meaningful speaking of prediction and confidence intervals.

I mention here the two because they are often confused.

Although both are centered at $\hat y$, the prediction interval is wider than the confidence interval, for a given $x$ and confidence level. This makes sense, since the prediction interval must take account of the tendency of y to fluctuate from its mean value, while the confidence interval simply needs to account for the uncertainty in estimating the mean value (source)

• I have an another question. I'm trying to have a prediction interval. TO do this, i'm using this kind of formula for a 95% prediction interval : y^t±1.96σ^ Where σ^ is an estimate of the standard deviation of the forecast distribution In forecasting. It says after that i can use the standard deviation of the residuals. What do you think about this ? See EDIT 2 for the article. – KIToRe Aug 4 '17 at 9:40