Conteúdo do Curso
Introduction to Finance with Python
Introduction to Finance with Python
Challenge: Autoregressive Model with Moving Average(ARMA)
What is a Moving Average?
Before discovering model, which this chapter is devoted to, it will be better to define basic concept, called Moving Average.
This model is denoted as MA(q)
, where q
- is model's parameter, which, analogically to AR
model called it's order, and corresponds to number of previous steps, from which errors are taken.
For example, here is an expression for MA(3)
model:
Here ε_k
- is an error on time step k
, which could be computed in the next way:
Here y_k
- is real value of time series at time step k
, while y_k_hat
- corresponding value, predicted by model.
We should mention, that practically - MA models are really used, but their combination with another models - is way more effective and popular thing.
What is an ARMA?
As well as before, autoregressive component (AR), uses previous values of time series for predicting future values.
Meanwhile, moving average component (MA) measures dependencies between future values and errors on previous values.
Defining model
In case of ARMA, model already has two parameters: as before - we use order of autoregression p
, but now - we are also using order of moving average q
, which is a number of previous steps, from which errors will be taken.
We will denote it like ARMA(p,q)
.
For example, model ARMA(2,3)
can be represented, using the next expression:
Here, y_t
- value of time series on time step t
, ε_t
- random error on step t
, c
- bias coefficient.
Code implementation
To implement and train ARMA model in Python we can use the following code:
To make future predictions, we can use just the same code, we used into previous chapter for AR model:
Tarefa
In this task you need to:
- Train
ARMA(5,2)
model on a prepared datasetdata
of Microsoft's stock prices.
Note: You need to pass data
as the first argument, without specifying name of corresponding parameter, in order to complete this chapter.
- Make forecast on the next 14 steps, using the trained model.
Obrigado pelo seu feedback!
Challenge: Autoregressive Model with Moving Average(ARMA)
What is a Moving Average?
Before discovering model, which this chapter is devoted to, it will be better to define basic concept, called Moving Average.
This model is denoted as MA(q)
, where q
- is model's parameter, which, analogically to AR
model called it's order, and corresponds to number of previous steps, from which errors are taken.
For example, here is an expression for MA(3)
model:
Here ε_k
- is an error on time step k
, which could be computed in the next way:
Here y_k
- is real value of time series at time step k
, while y_k_hat
- corresponding value, predicted by model.
We should mention, that practically - MA models are really used, but their combination with another models - is way more effective and popular thing.
What is an ARMA?
As well as before, autoregressive component (AR), uses previous values of time series for predicting future values.
Meanwhile, moving average component (MA) measures dependencies between future values and errors on previous values.
Defining model
In case of ARMA, model already has two parameters: as before - we use order of autoregression p
, but now - we are also using order of moving average q
, which is a number of previous steps, from which errors will be taken.
We will denote it like ARMA(p,q)
.
For example, model ARMA(2,3)
can be represented, using the next expression:
Here, y_t
- value of time series on time step t
, ε_t
- random error on step t
, c
- bias coefficient.
Code implementation
To implement and train ARMA model in Python we can use the following code:
To make future predictions, we can use just the same code, we used into previous chapter for AR model:
Tarefa
In this task you need to:
- Train
ARMA(5,2)
model on a prepared datasetdata
of Microsoft's stock prices.
Note: You need to pass data
as the first argument, without specifying name of corresponding parameter, in order to complete this chapter.
- Make forecast on the next 14 steps, using the trained model.
Obrigado pelo seu feedback!
Challenge: Autoregressive Model with Moving Average(ARMA)
What is a Moving Average?
Before discovering model, which this chapter is devoted to, it will be better to define basic concept, called Moving Average.
This model is denoted as MA(q)
, where q
- is model's parameter, which, analogically to AR
model called it's order, and corresponds to number of previous steps, from which errors are taken.
For example, here is an expression for MA(3)
model:
Here ε_k
- is an error on time step k
, which could be computed in the next way:
Here y_k
- is real value of time series at time step k
, while y_k_hat
- corresponding value, predicted by model.
We should mention, that practically - MA models are really used, but their combination with another models - is way more effective and popular thing.
What is an ARMA?
As well as before, autoregressive component (AR), uses previous values of time series for predicting future values.
Meanwhile, moving average component (MA) measures dependencies between future values and errors on previous values.
Defining model
In case of ARMA, model already has two parameters: as before - we use order of autoregression p
, but now - we are also using order of moving average q
, which is a number of previous steps, from which errors will be taken.
We will denote it like ARMA(p,q)
.
For example, model ARMA(2,3)
can be represented, using the next expression:
Here, y_t
- value of time series on time step t
, ε_t
- random error on step t
, c
- bias coefficient.
Code implementation
To implement and train ARMA model in Python we can use the following code:
To make future predictions, we can use just the same code, we used into previous chapter for AR model:
Tarefa
In this task you need to:
- Train
ARMA(5,2)
model on a prepared datasetdata
of Microsoft's stock prices.
Note: You need to pass data
as the first argument, without specifying name of corresponding parameter, in order to complete this chapter.
- Make forecast on the next 14 steps, using the trained model.
Obrigado pelo seu feedback!
What is a Moving Average?
Before discovering model, which this chapter is devoted to, it will be better to define basic concept, called Moving Average.
This model is denoted as MA(q)
, where q
- is model's parameter, which, analogically to AR
model called it's order, and corresponds to number of previous steps, from which errors are taken.
For example, here is an expression for MA(3)
model:
Here ε_k
- is an error on time step k
, which could be computed in the next way:
Here y_k
- is real value of time series at time step k
, while y_k_hat
- corresponding value, predicted by model.
We should mention, that practically - MA models are really used, but their combination with another models - is way more effective and popular thing.
What is an ARMA?
As well as before, autoregressive component (AR), uses previous values of time series for predicting future values.
Meanwhile, moving average component (MA) measures dependencies between future values and errors on previous values.
Defining model
In case of ARMA, model already has two parameters: as before - we use order of autoregression p
, but now - we are also using order of moving average q
, which is a number of previous steps, from which errors will be taken.
We will denote it like ARMA(p,q)
.
For example, model ARMA(2,3)
can be represented, using the next expression:
Here, y_t
- value of time series on time step t
, ε_t
- random error on step t
, c
- bias coefficient.
Code implementation
To implement and train ARMA model in Python we can use the following code:
To make future predictions, we can use just the same code, we used into previous chapter for AR model:
Tarefa
In this task you need to:
- Train
ARMA(5,2)
model on a prepared datasetdata
of Microsoft's stock prices.
Note: You need to pass data
as the first argument, without specifying name of corresponding parameter, in order to complete this chapter.
- Make forecast on the next 14 steps, using the trained model.