You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/posts/finance/stock_prediction/ARIMA/index.md
+186-17
Original file line number
Diff line number
Diff line change
@@ -12,8 +12,6 @@ hero: images/test_forecast.png
12
12
tags: ["Finance", "Statistics", "Forecasting"]
13
13
categories: ["Finance"]
14
14
---
15
-
16
-
17
15
## 1. Introduction
18
16
19
17
Time series analysis is a fundamental technique in quantitative finance, particularly for understanding and predicting stock price movements. Among the various time series models, ARIMA (Autoregressive Integrated Moving Average) models have gained popularity due to their flexibility and effectiveness in capturing complex patterns in financial data.
@@ -46,6 +44,7 @@ ARIMA models combine three components:
46
44
3.**MA (Moving Average)**: The model uses the dependency between an observation and a residual error from a moving average model applied to lagged observations.
47
45
48
46
The ARIMA model is typically denoted as ARIMA(p,d,q), where:
47
+
49
48
- p is the order of the AR term
50
49
- d is the degree of differencing
51
50
- q is the order of the MA term
@@ -56,9 +55,11 @@ The ARIMA model can be written as:
- $Y_t$ is the differenced series (it may have been differenced more than once)
63
64
-**c** is a constant
64
65
- $\phi_i$ are the parameters of the autoregressive part
@@ -118,8 +119,9 @@ if p_val > 0.05:
118
119
119
120
print(f"\nd = {d}")
120
121
```
122
+
121
123
> *Output:*
122
-
>
124
+
>
123
125
> d = 1
124
126
125
127

@@ -135,19 +137,21 @@ Choosing the right ARIMA model involves selecting appropriate values for p, d, a
135
137
3.**Diagnostic checking**: Analyzing residuals to ensure they resemble white noise.
136
138
137
139
### Finding ARIMA Parameters (p, d, q)
140
+
138
141
Determining the optimal ARIMA parameters involves a combination of statistical tests, visual inspection, and iterative processes. Here's a systematic approach to finding p, d, and q:
139
142
140
-
* Determine d (Differencing Order):
143
+
* Determine d (Differencing Order):
141
144
- Use the Augmented Dickey-Fuller test to check for stationarity.
142
145
- If the series is not stationary, difference it and test again until stationarity is achieved.
143
-
* Determine p (AR Order) and q (MA Order):
146
+
* Determine p (AR Order) and q (MA Order):
144
147
- After differencing, use ACF (Autocorrelation Function) and PACF (Partial Autocorrelation Function) plots.
145
148
- The lag where the ACF cuts off indicates the q value.
146
149
- The lag where the PACF cuts off indicates the p value.
147
150
* Fine-tune with Information Criteria:
148
151
- Use AIC (Akaike Information Criterion) or BIC (Bayesian Information Criterion) to compare different models.
149
152
150
153
### Finding d parameter from plots
154
+
151
155
Since, the stationary was already checkd in the previous, this paragraph is useful for graphical and comphrension purpose. Moreover, with autocorrelation parameters, it is possible to find better values of d that the ADF test cannot recognize.
152
156
153
157
```python
@@ -174,19 +178,21 @@ plot_acf(df.Close.diff().diff().dropna(), ax=axes[2, 1], lags=len(df)/7-3, color
174
178
plt.tight_layout()
175
179
plt.show()
176
180
```
181
+
177
182

178
183
179
-
Indeed, from the plot, *d=2* is probably a better solution since we have few coefficient that goes above the confidence threshold.
184
+
Indeed, from the plot, *d=2* is probably a better solution since we have few coefficient that goes above the confidence threshold.
180
185
181
186
### Finding p parameter from plots
187
+
182
188
As suggest previously, Partical Correlation Plot is adopted to find the **p** parameter.
print(f"Best ARIMA order based on grid search: {best_order}")
374
+
```
375
+
376
+
> Suggested d value: 1
377
+
>
378
+
> temp best: (1, 1, 1) 0.14570196898952395
379
+
>
380
+
> temp best: (1, 1, 5) 0.14514639508226412
381
+
>
382
+
> temp best: (1, 1, 6) 0.14499024417142595
383
+
>
384
+
> temp best: (1, 1, 7) 0.1439625731680348
385
+
>
386
+
> temp best: (1, 2, 1) 0.07729490750827837
387
+
>
388
+
> temp best: (1, 2, 2) 0.0764917667521908
389
+
>
390
+
> temp best: (3, 2, 4) 0.07647187068962996
391
+
>
392
+
> Best ARIMA order based on grid search: (3, 2, 4)
393
+
394
+
In g
395
+
396
+
## 7. Limitations and Considerations
228
397
229
398
While ARIMA models can be powerful for time series prediction, they have limitations:
230
399
@@ -234,15 +403,6 @@ While ARIMA models can be powerful for time series prediction, they have limitat
234
403
4.**Assumption of constant variance**: This may not hold for volatile stock prices.
235
404
5.**No consideration of external factors**: ARIMA models only use past values of the time series, ignoring other potentially relevant variables.
236
405
237
-
## 7. Advanced Topics and Extensions
238
-
239
-
Several extensions to basic ARIMA models address some of these limitations:
240
-
241
-
1.**SARIMA**: Incorporates seasonality
242
-
2.**ARIMAX**: Includes exogenous variables
243
-
3.**GARCH**: Models time-varying volatility
244
-
4.**Vector ARIMA**: Handles multiple related time series simultaneously
245
-
246
406
## 8. Conclusion
247
407
248
408
Time series analysis and ARIMA models provide valuable tools for understanding and predicting stock price movements. While they have limitations, particularly in the complex and often non-linear world of financial markets, they serve as a strong foundation for more advanced modeling techniques.
@@ -257,3 +417,12 @@ When applying these models to real-world financial data, it's crucial to:
257
417
258
418
As with all financial modeling, remember that past performance does not guarantee future results. Time series models should be one tool in a broader analytical toolkit, complemented by fundamental analysis, market sentiment assessment, and a deep understanding of the specific stock and its market context.
259
419
420
+
### Next Steps
421
+
422
+
In next articles, we are going to explore about time-series decomposition, seasanality, exogenous variables.
423
+
Indeed, several extensions to basic ARIMA models address some of these limitations:
424
+
425
+
1.**SARIMA**: Incorporates seasonality.
426
+
2.**ARIMAX**: Includes exogenous variables.
427
+
3.**GARCH**: Models time-varying volatility.
428
+
4.**Vector ARIMA**: Handles multiple related time series simultaneously.
<h5class="card-title">Time Series Analysis and ARIMA Models for Stock Price Prediction</h5>
306
-
<pclass="card-text post-summary">Time Series Analysis and ARIMA Models for Stock Price Prediction 1. Introduction Time series analysis is a fundamental technique in quantitative finance, particularly for understanding and predicting stock price movements. Among the various time series models, ARIMA (Autoregressive Integrated Moving Average) models have gained popularity due to their flexibility and effectiveness in capturing complex patterns in financial data.
307
-
This article will explore the application of time series analysis and ARIMA models to stock price prediction.</p>
306
+
<pclass="card-text post-summary">1. Introduction Time series analysis is a fundamental technique in quantitative finance, particularly for understanding and predicting stock price movements. Among the various time series models, ARIMA (Autoregressive Integrated Moving Average) models have gained popularity due to their flexibility and effectiveness in capturing complex patterns in financial data.
307
+
This article will explore the application of time series analysis and ARIMA models to stock price prediction. We’ll cover the theoretical foundations, practical implementation in Python, and critical considerations for using these models in real-world financial scenarios.</p>
308
308
</a>
309
309
310
310
<divclass="tags">
@@ -327,7 +327,7 @@ <h5 class="card-title">Time Series Analysis and ARIMA Models for Stock Price Pre
<description>Time Series Analysis and ARIMA Models for Stock Price Prediction 1. Introduction Time series analysis is a fundamental technique in quantitative finance, particularly for understanding and predicting stock price movements. Among the various time series models, ARIMA (Autoregressive Integrated Moving Average) models have gained popularity due to their flexibility and effectiveness in capturing complex patterns in financial data.
16
-
This article will explore the application of time series analysis and ARIMA models to stock price prediction.</description>
15
+
<description>1. Introduction Time series analysis is a fundamental technique in quantitative finance, particularly for understanding and predicting stock price movements. Among the various time series models, ARIMA (Autoregressive Integrated Moving Average) models have gained popularity due to their flexibility and effectiveness in capturing complex patterns in financial data.
16
+
This article will explore the application of time series analysis and ARIMA models to stock price prediction. We&rsquo;ll cover the theoretical foundations, practical implementation in Python, and critical considerations for using these models in real-world financial scenarios.</description>
<h5class="card-title">Time Series Analysis and ARIMA Models for Stock Price Prediction</h5>
442
-
<pclass="card-text post-summary">Time Series Analysis and ARIMA Models for Stock Price Prediction 1. Introduction Time series analysis is a fundamental technique in quantitative finance, particularly for understanding and predicting stock price movements. Among the various time series models, ARIMA (Autoregressive Integrated Moving Average) models have gained popularity due to their flexibility and effectiveness in capturing complex patterns in financial data.
443
-
This article will explore the application of time series analysis and ARIMA models to stock price prediction.</p>
442
+
<pclass="card-text post-summary">1. Introduction Time series analysis is a fundamental technique in quantitative finance, particularly for understanding and predicting stock price movements. Among the various time series models, ARIMA (Autoregressive Integrated Moving Average) models have gained popularity due to their flexibility and effectiveness in capturing complex patterns in financial data.
443
+
This article will explore the application of time series analysis and ARIMA models to stock price prediction. We’ll cover the theoretical foundations, practical implementation in Python, and critical considerations for using these models in real-world financial scenarios.</p>
444
444
</a>
445
445
446
446
<divclass="tags">
@@ -463,7 +463,7 @@ <h5 class="card-title">Time Series Analysis and ARIMA Models for Stock Price Pre
<description>Time Series Analysis and ARIMA Models for Stock Price Prediction 1. Introduction Time series analysis is a fundamental technique in quantitative finance, particularly for understanding and predicting stock price movements. Among the various time series models, ARIMA (Autoregressive Integrated Moving Average) models have gained popularity due to their flexibility and effectiveness in capturing complex patterns in financial data.
16
-
This article will explore the application of time series analysis and ARIMA models to stock price prediction.</description>
15
+
<description>1. Introduction Time series analysis is a fundamental technique in quantitative finance, particularly for understanding and predicting stock price movements. Among the various time series models, ARIMA (Autoregressive Integrated Moving Average) models have gained popularity due to their flexibility and effectiveness in capturing complex patterns in financial data.
16
+
This article will explore the application of time series analysis and ARIMA models to stock price prediction. We&rsquo;ll cover the theoretical foundations, practical implementation in Python, and critical considerations for using these models in real-world financial scenarios.</description>
0 commit comments