type
Post
Created date
Jun 16, 2022 01:21 PM
category
Data Science
tags
Applied forecasting
Economics
status
Published
Language
From
summary
slug
password
Author
Priority
Featured
Featured
Cover
Origin
Type
URL
Youtube
Youtube
icon
5.2. Some simple forecasting methods. 2
The following 4 forecasting methods that we will use are benchmarks for other forecasting methods. They are very simple and surprisingly effective.
- MEAN(y): Average method
- NAIVE(y): Naïve method
- SNAIVE(y ~ lag(m)): Seasonal naïve method
- RW(y ~ drift()): Drift method
Above, Naive assumes the most recent observation is the most important one, and all previous obs provides no information about the future.
MEAN(y)
: Average method![notion image](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2F60e06240-86c6-4a65-9845-a36174a84892%2FUntitled.png%3Ftable%3Dblock%26id%3D6acb98fb-0dec-4439-9f4c-5573fff3b116%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725480000000%26signature%3DK6HcWbGWCPpaZleSVN7SzVZYIDFg77SwepR7gHIwPWo?table=block&id=6acb98fb-0dec-4439-9f4c-5573fff3b116&cache=v2)
Forecast of all future values = mean of historical data {y1, . . . , yT}.
SNAIVE(y ~ lag(m))
: Seasonal naïve method![notion image](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2F2bccbef7-9406-49f9-9fda-3db2a0c55265%2FUntitled.png%3Ftable%3Dblock%26id%3D8ca03033-f055-4e89-86e5-45034d67a28b%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725480000000%26signature%3DaDZYX89fJedUQ6ziAVMIv3i6sMCSe4xydtlEMUQqZzQ?table=block&id=8ca03033-f055-4e89-86e5-45034d67a28b&cache=v2)
Forecasts = last value from same period a season ago.
You take the last m of observed data; in this case, this is quarterly data so m = 4. So you take the last 4 values, and then your future values are the same as those ones for all future years
NAIVE(y)
: Naïve method![notion image](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2Fcbf288ae-f2f7-4fdd-8554-84e35b90ff03%2FUntitled.png%3Ftable%3Dblock%26id%3Da72770e0-2b98-4cf4-99dc-637abc603212%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725480000000%26signature%3DBJmPGlUFqyPKsbtQ8Q_AgIGRbFokpie3SiQ_TPYnqBw?table=block&id=a72770e0-2b98-4cf4-99dc-637abc603212&cache=v2)
Forecasts = last observed value.
RW(y ~ drift())
: Drift method![notion image](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2F5ab613c0-fb8e-4077-a35d-60132906daf8%2FUntitled.png%3Ftable%3Dblock%26id%3Dd0c86d42-071f-4156-b03f-b7f2f4c79abc%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725480000000%26signature%3DNr6Y8-LEniJwqsRrbXY5C5x7X0SK5OiF19-cSphJHx0?table=block&id=d0c86d42-071f-4156-b03f-b7f2f4c79abc&cache=v2)
Forecasts = last value plus average change from period to period
You may ask what's the average amount it's changed from period to period and that's what we expect it to continue to change into the future. So, you take your last value plus that amount of change for all future periods.
5.3. Residual diagnostics
5.2.2. Fitted values
- Each observation in a time series can be forecast using all previous observations. We call these Fitted values.
![notion image](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2F3929099f-2d8b-4d35-81e8-4c9e80b954e5%2FUntitled.png%3Ftable%3Dblock%26id%3D8b0de6e7-bf4d-4d69-bfa9-9cd6ce172568%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725480000000%26signature%3DgEYxFGX5cJeekdmtWGt8DRY2_ZOMKZ5cTHlY37EBGQo?table=block&id=8b0de6e7-bf4d-4d69-bfa9-9cd6ce172568&cache=v2)
5.2.3. Forecasting residuals
- Define difference between observed value and its fitted value:
- Useful in checking whether a model has adequately captured the information in the data.
- A good forecasting method has the following assumptions and useful properties :
There are 2 ways to check residuals; one by treating residual individually (i.e. ACF of residuals) , another one by treating residuals as a group (Portmanteau tests)
5.2.4. ACF of residuals.
![notion image](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2F27e95f6c-7aa7-4767-9cdd-f2b843c6dbf1%2FUntitled.png%3Ftable%3Dblock%26id%3D21af701a-5bb6-476e-a08a-f371670342ee%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725480000000%26signature%3DDP86CpsLN6vNFN8IfASaFv0Sh8MXdwiSD5ll6YfxQ68?table=block&id=21af701a-5bb6-476e-a08a-f371670342ee&cache=v2)
Interpretation
These graphs show that the naïve method produces forecasts that appear to account for all available information.
The mean of the residuals is close to zero and there is no significant correlation in the residuals series.
The time plot of the residuals shows that the variation of the residuals stays much the same across the historical data, apart from the one outlier, and therefore the residual variance can be treated as constant.
This can also be seen on the histogram of the residuals. The histogram suggests that the residuals may not be normal — the right tail seems a little too long, even when we ignore the outlier.
Consequently, forecasts from this method will probably be quite good, but prediction intervals that are computed assuming a normal distribution may be inaccurate.
- Assume residuals are white noise (uncorrelated, mean zero, constant variance).
- If they aren’t, then there is information left in the residuals that should be used in computing forecasts.
5.2.5. Portmanteau tests
- A more formal test for autocorrelation by considering a whole set of values as a group
- A test to see whether the set is significantly different from a zero set.
5.4. Distributional forecasts and prediction intervals
5.4.1. Forecast distributions
- A forecast is (usually) the mean of the conditional distribution .
- Most time series models produce normally distributed forecasts.
- The forecast distribution describes the probability of observing any future value.
5.4.2. Prediction intervals
- A prediction interval gives a region within which we expect to lie with a specified probability.
- Assuming forecast errors are normally distributed, then a 95% PI is ; where is the st dev of the h-step distribution.
- When h = 1, can be estimated from the residuals.
brick_fc %>% hilo(level = 95)
- Point forecasts often useless without a measure of uncertainty (such as prediction intervals).
- Prediction intervals require a stochastic model (with random errors, etc).
- For most models, prediction intervals get wider as the forecast horizon increases.
- Use level argument to control coverage. Check residual assumptions before believing them.
- Usually too narrow due to unaccounted uncertainty.
5.5. Forecasting with transformations
5.5.1. Modelling with transformations
5.5.2. Forecasting with transformations
5.5.3. Bias adjustment
ETC3550 Lecture 5A - YouTube Here mentions :
If this probability is some number — p, then the probability of the transformation must also be that number p.
- because the amount of probability of the amount of mass — the density mass — is going to be the same as whatever sits in here.
- So. probabilities are preserved (i.e., identical), at least in terms of the quantiles of the distribution.
5.6. Forecasting and decomposition
Since we have learnt how to decompose the time series into 3 components (T= S+T_R), we now can first forecast the components and then combine them into one forecast.
- Fit a decomposition model which involves both an STL decomposition followed by separate models for the seasonally adjusted series and the seasonal component.
- When I produce forecasts of that, it's a forecast of the original series.
- Under decomposition, model understands it's going to put these together at the end of the day
- it looks to see what the model is for the seasonal component and what the model is for the adjusted component and adds them together to get forecasts of the original series
- that's what it comes back with a forecast of the original series in the usual format the distribution and then the mean of the distribution
## use the function decomposition model ## 1 dcmp <- decomposition_model( STL(Employed), NAIVE(season_adjust), SNAIVE(season_year) ) ## 2 us_retail_employment %>% model(stlf = dcmp) %>% forecast()%>% autoplot()
5.7. 7 Evaluating forecast accuracy
5.7.1. Training and test sets
- Same as the ones taught in ETC3250.
5.7.2. Forecast errors
- Errors are not the same as the residual (Here).
5.7.3. Measures of forecast accuracy
for the notation above,
- y t plus h is the t plus h th observation
- y hat t plus h was given t is the forecast based on data up until the end of the training set
- e t plus h is the difference between the two
Example of Scale independent:
If the unit of e is a dollar, the units of e in MAE, and RMSE are dollar; but the unit of MSE is dollar ^2.
MAPE is a common metric to be used in the industry. But it has drawbacks: 1) yt has to be positive. 2) y has an absolute 0.
So Rob invented one that called MASE. ->>>>
Mean Error (ME) and Mean Percentage Error (MPE) are measure of bias, rather than accuracy, which Rob do not normally look at.
![notion image](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2Fa575066b-0b8d-445e-b973-111c9ae3dfbc%2FUntitled.png%3Ftable%3Dblock%26id%3D973386c6-011d-4ad6-bd12-c5507eb07353%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725480000000%26signature%3DXay4yX3-3Wwi-vvxns78n8-5FMsoAwVkqmSjJqrz9mQ?table=block&id=973386c6-011d-4ad6-bd12-c5507eb07353&cache=v2)
![notion image](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2F670796a5-480c-40b5-8997-7199f170192a%2FUntitled.png%3Ftable%3Dblock%26id%3Dbe228223-aef6-491d-bfab-59d84734db21%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725480000000%26signature%3DWUu9P5vtZqYAuOwIlGmFb_m8feX5PeK3ogyqBhQ9Itw?table=block&id=be228223-aef6-491d-bfab-59d84734db21&cache=v2)
![notion image](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2Fb0ff5173-1e68-4358-bfb7-176a7a6b1d4e%2FUntitled.png%3Ftable%3Dblock%26id%3D8380c041-2d4e-463a-84a8-62f0ded63bdb%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725480000000%26signature%3DvU4bIXVJBdM630xTUia7dV6MjDqLO2cqwiE5TGblW_Q?table=block&id=8380c041-2d4e-463a-84a8-62f0ded63bdb&cache=v2)
![notion image](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2F5ca242fa-fa84-4031-b4ce-1fab7e5590e5%2FUntitled.png%3Ftable%3Dblock%26id%3D189b2474-d99a-4de9-9242-5a4c7d41dea5%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725480000000%26signature%3DG7cOPaSjz6ghvjkpPC4dUEFQbt-HIfLfeykMEVLtBTs?table=block&id=189b2474-d99a-4de9-9242-5a4c7d41dea5&cache=v2)
![notion image](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2F2f94ebf8-8099-4f6d-a9f3-d0bf5265f016%2FUntitled.png%3Ftable%3Dblock%26id%3D03a57b21-b952-4e6c-8328-d246435f95a8%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725480000000%26signature%3DSEr2okr_kJhVP5jeo-kqv9wXxFq0JpNOK6kuTZKBqHU?table=block&id=03a57b21-b952-4e6c-8328-d246435f95a8&cache=v2)
5.8. 8 Time series cross-validation 2. 4
FAQ
What is the assumption of residuals?
How do I know if the residuals are uncorrelated?
![notion image](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2F1c1961cb-70f8-45ac-8df7-e1a4a141b303%2FUntitled.png%3Ftable%3Dblock%26id%3Df9b30a04-66d3-4598-9be6-0cd2ceb136f5%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725480000000%26signature%3DbZMqE582zasbxiSEyGL-5-IbO-rzZJ5UE9_-8-26uLA?table=block&id=f9b30a04-66d3-4598-9be6-0cd2ceb136f5&cache=v2)
- Author:Jason Siu
- URL:https://jason-siu.com/article%2Fd5aa9805-dbf7-4e29-a969-78154258db40
- Copyright:All articles in this blog, except for special statements, adopt BY-NC-SA agreement. Please indicate the source!
Relate Posts