Assignment codes for Time Series (2020, FGV).
In this repository, we study several topics included in Time Series subject, such as ARIMA models, trend and seasonality. Each homework has a pratical study and some theoretical questions. Alternative projects to the beggining of the course (Covid-19 deaths analysis and homework 1) can be found in this repository.
The homeworks and assigments are coded in R language and the presentations and texts are in Portuguese. If requested, the authors can translate it.
R is the classic programming language for statistics. It has some limitations when compared to other languages, but some packages make it more worthy, as:
ggplot
: best tool for plotting in Rtseries
andzoo
: good for dealing more easily with time series.forecast
: the best when we speak about estimation and predictions of the models.
A pratical study of Car's Sales in Norway. In this study we practice the following modelling:
- Decomposition in Seasonal, Trend and Remainder of a Time Series;
- Polynomial regression for trend and seasonality;
- Holt-Winters and Exponential Smoothing.
After each modelling, we compared the models using the Mean Absolute Percentage Error.
Above you can see the moving average decomposition and the final comparison among the models.
Identification of ARMA models, considering the Autocorrelation and Partial Autocorrelation of the series.
By looking the image, the behaviour of the graphic can identify, initially, a model.
We have some theorical exercises about differenciation and stationarity of ARIMA process. Also we construct by simulation the distribution of the statistic of Adjusted Dickey-Fuller (ADF) Test. In the end we identify an ARIMA model for the IPCA (inflation) series. We considered a variance stabilizer. So as to identify the model, we use the ACF and PACF graphics combined by the Information Criterion, as AIC, BIC and AICc.
For each considered model, we studied the residuals of the estimated model.
We used the method Box-Jenkins in order to understand a time series as an ARIMA model. We can summarize it as:
- Box-Cox transformation to stabilize the variance.
- Identify the ARIMA(p,d,q) model:
- Check the stationarity of the series with ADF test and differentiate if necessary (d times)
- Visualize the ACF and PACF of the data.
- Compare AIC, BIC and AICc information and select p and q.
- Estimation of the parameters of the model through maximum likelihood.
- Diagnose the residuals (remainder of the fitting):
- Visualize the residuals.
- Plot histogram, autocorrelation and partial autocorrelation.
- Ljung-Box's test for de-correlation and Jarque-Bera's test for kurtosis and skewness' normality.
More exercises about transformation of a time series. We study the Box-Jenkins method considering seasonality. In this case, it's important to use Kruskal-Wallis test for seasonality and differentiate D times considering this. The information criterion and ACF can be used as well. As example, we used the expenses in coffees, restaurants and other in Australia.
The assigments are application of this methods in more difficult series. It's suggested to have a look in the pdfs available in the assigment's folder.