1. This document analyzes temperature data from three cities in Portugal - Beja, Lisbon, and Porto - from 1971 to 2018.
2. The empirical work section describes data collection from the Climate Portal, preparation including transforming the data to make it stationary, and modeling using ARIMA and SARIMA techniques.
3. Results show the average temperature has increased in all three cities over time, with Beja having the highest temperatures. The models produced good ex-post and ex-ante forecasts of the temperature data.
Call Now ☎️🔝 9332606886 🔝 Call Girls ❤ Service In Muzaffarpur Female Escorts ...
Climate Change in Portugal
1. CLIMATE CHANGE
IN PORTUGAL
Programming Techniques
Group number 2
Catarina Pereira, 52919
Cristiana Correia, 48576
Mariana Canavarro, 48809
Tiago Pires, 48816
2. SUMMARY
1. Literature review
2. Empirical work
4. Conclusion
2.1. Data context
2.2. Data collection
2.3. Data preparation
2.4. Exploring data
2.5. Data modelling
3. Results and discussing
2.6. Evaluation
2.7. Deployment
3. 1. LITERATURE
REVIEW
• We studied the average temperature in Portugal
for the past 50 years in Beja, Lisbon and Porto.
• The increase in temperature is one of the most
controversial issues in nowadays.
• As climate slowly and gradually changes human
race as a high capacity to adapt, but it’s not
possible to predict the impact that it will have on
our daily life’s, said Zivin and Neidell (2014).
4. 2. EMPIRICAL WORK
2.1. Data context
1
Stationary Time Series Model
(ARMA Model)
Time process where mean, variance
and autocorrelation remain
constant over time.
2
Non Stationary Time Series
Model (ARIMA Model)
Time Series with trend and
seasonality. Have no constant
mean over time (average depends
on time) or constant variance over
time.
3
Seasonal Time Series Models
(S-ARIMA Model)
Time Series that contains
seasonal phenomena that
repeats itself over a regular
period of time.
5. 2.2. Data collection
2. EMPIRICAL WORK
• Our sample were collected from the Climate Portal
• We obtain data on the average temperature in 3 cities in Portugal: Beja, Lisboa and Porto
• From January 1971 to December 2018
• In total 576 observations
• The data came in a file in Excel format
6. 2.3. Data preparation
2. EMPIRICAL WORK
1
2
3
Create 3 Python files, corresponding to the 3 cities we studied: Porto, Lisbon
and Beja.
Import the libraries we wanted to use, such as numpy, pandas,
statsmodels.api, statsmodels.tsa and also matplotlib.pyplot.
Define the variables: “dataset”, our main variable; “Data70” is the variable
that represents the observations up to the last year (excluding).
Define a correlation function (acf_pacf (x)) that will allow us to evaluate the
stationarity of our model.
4
7. 2.4. Exploring data
2. EMPIRICAL WORK
We started plotting the original series chart to get a first visual idea of the behavior of the series.
So we essentially check if it has a tendency, if the variance is constant and if it has seasonality.
We can already see that the series does not have a marked trend and the variance does not
seem constant. Right here we suspect that the series is not stationary.
Figure 1. Original Serie
8. 2.4. Exploring data
2. EMPIRICAL WORK
Figure 2. ACF/PACF from original series
Analyzing Figure 2 we can verify that the autocorrelation of the series does not slowly decay
to zero nor disappear after a certain delay. The same goes for PACF. We conclude that the
series is not stationary, so it needs transformations to become stationary and therefore can
be modeled.
9. 2.4. Exploring data
2. EMPIRICAL WORK
Given the problems that make the series
non-stationary, the non-constant
variance and the seasonal component,
we applied two usual techniques:
• Logarithmization, so that the variance
becomes constant;
• Differentiation of order 12, to remove
the autocorrelations caused by
seasonality.
Figure 3. Logarithmization and differentiation (order 12)
Figure 4. ACF and PACF of figure 3
10. 2.5. Data modelling
2. EMPIRICAL WORK
• Since we have already made the necessary
transformations so that our series is stationary, we now
need to know the number of optimal parameters
associated with seasonal and non-seasonal parts MA
and AR, which best fit our data. Consequently we run
the auto-arima function in python.
• The model with the best
information criterion is an
S-ARIMA (1,0,2) * (0,1,1)12.
11. 2.5. Evaluation
2. EMPIRICAL WORK
The estimation of the model coefficients was performed based on the observations
collected up to the last year of the sample, that is, with the variable we created
“data70”. The model estimation result is given by the following output.
Figure 5. Model estimation output
1 − 0,9732𝐵 (1 − 𝐵12
)𝑍𝑡 = (1 − 0,7088𝐵 − 0,1695𝐵2
)(1 − 0,8303𝐵12
)𝑎𝑡
12. 2.6. Evaluation
2. EMPIRICAL WORK
After estimating the model, we need to check if it has statistical properties that allow a
good prediction.
Figure 6. Model Residue Analysis
13. 2.6. DEPLOYMENT
2. EMPIRICAL WORK
Ex-post forecasting, which consists of “predicting” what has already happened to analyze
forecasting behavior, a kind of training phase before we try to predict the future.
Figure 7. Ex post forecasting for the last 12 sample
observations
Figure 8. Absolute error percentage
14. 2.6. DEPLOYMENT
2. EMPIRICAL WORK
Ex-Ante Forecasting, which consists of forecasting the data of the variable under study for a future
moment.
Figure 9. Ex-ante forecasting: predict the next 12 upcoming future
15. 3. RESULTS AND DISCUSSING
Figure 10. Porto’s Original Series Figure 11. Lisbon’s Original Series Figure 12. Beja’s Original Series
Beja is the city with higher amplitude and higher temperatures, compared with Porto and Lisbon.
Figure 13. Porto’s moving average
(MA) and moving standard
deviation (MSD)
Figure 14. Lisbon’s MA and MSD Figure 15. Beja’s MA and MSD
In all three cities the average temperature has been increasing, the average and the standard deviation
have demonstrated a small but noticeable raise during our time frame.
16. 3. RESULTS AND DISCUSSING
Analysing the three cities in
discussion we can say the S-ARIMA
(1,1,1)(0,1,1,12) did a good
prediction of all time series.
Figure 16. Porto’s Ex-post forecasting
Figure 17. Lisbon’s Ex-post forecasting Figure 18. Beja’s Ex-post forecasting
17. 3. RESULTS AND DISCUSSING
The amplitude of temperature will continue to decrease,
especially in Porto city, despite the increase in average
temperature. Lisbon will apparently maintain its
amplitude of temperate and average temperature. And
finally, Faro will remain the city with the most observed
amplitude followed by the slight increase of minimum
temperatures.
Figure 19. Porto’s Ex-ante forecasting Figure 20. Lisbon’s Ex-ante forecasting
Figure 21. Beja’s Ex-ante forecasting