Econometrics - miniproject

Financial Econometrics

1 Group 7 member

  1. Nguyễn Ngọc Kim Chi - MAMAIU20034
  2. Phạm Thị Trúc Na - MAMAIU20098
  3. Nguyễn Ngọc Khánh Minh - MAMAIU20026
  4. Lê Ngọc Yến - MAMAIU20059

2 Library

library(lmtest)
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
library(forecast)
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
library(readxl)
library(e1071)
library(ggplot2)
library(tseries)
library(psych)
## 
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
## 
##     %+%, alpha

3 Data Descriptive

library(readxl)
FPT_Data <- read_excel("E:/FE/FPT-Data.xlsx", 
     col_types = c("date", "numeric"))
View(FPT_Data)
mean(FPT_Data$price)
## [1] 77887.95
median(FPT_Data$price)
## [1] 74279
sd(FPT_Data$price)
## [1] 17388.93
var(FPT_Data$price)
## [1] 302374866
skewness(FPT_Data$price)
## [1] 1.029726
kurtosis(FPT_Data$price)
## [1] 1.427711
quantile(FPT_Data$price, probs = c(0.25, 0.5, 0.75))
##     25%     50%     75% 
## 67794.5 74279.0 85001.5
range(FPT_Data$price)
## [1]  41164.9 138000.0
nrow(FPT_Data) # number of observations
## [1] 848

The time series plots for all time series:

  1. FPT stock price series
# Plot time series data
ggplot(FPT_Data, aes(x = date, y = price)) +
  geom_line() +
  labs(title = "",
       x = "Date",
       y = "FPT Stock Price")

  1. The 1st difference series
#Plot first difference series data
FPT_Data$dprice = c(NA,diff(FPT_Data$price))

library(ggplot2)

ggplot(FPT_Data, aes(x = date, y = dprice)) +
  geom_line() +
  labs(title = "",
       x = "Date",
       y = "FPT 1st difference")
## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_line()`).

  1. The log return series
#Plot log return series data
FPT_Data$logret = c(NA, diff(log(FPT_Data$price)))
                    

ggplot(FPT_Data, aes(x = date, y = logret)) +
  geom_line() +
  labs(title = "",
       x = "Date",
       y = "FPT Log return")
## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_line()`).

4 Results & Discussion

4.1 Testing for stationarity

4.1.1 The Augmented Dickey-Fuller (ADP) test

  1. ADF test using adf.test()
  • The adf.test() from the tseries package will do a Augmented Dickey-Fuller test (Dickey-Fuller if we set lags equal to 0) with a trend and an intercept.
FPT_Data = FPT_Data [-1,] ##drop observations (NA) unless necessary
adf.test(FPT_Data$price)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  FPT_Data$price
## Dickey-Fuller = -1.2477, Lag order = 9, p-value = 0.8968
## alternative hypothesis: stationary
adf.test(FPT_Data$dprice)
## Warning in adf.test(FPT_Data$dprice): p-value smaller than printed p-value
## 
##  Augmented Dickey-Fuller Test
## 
## data:  FPT_Data$dprice
## Dickey-Fuller = -8.0663, Lag order = 9, p-value = 0.01
## alternative hypothesis: stationary
adf.test(FPT_Data$logret)
## Warning in adf.test(FPT_Data$logret): p-value smaller than printed p-value
## 
##  Augmented Dickey-Fuller Test
## 
## data:  FPT_Data$logret
## Dickey-Fuller = -8.3715, Lag order = 9, p-value = 0.01
## alternative hypothesis: stationary
  1. ADF test using ur.df()
  • The ur.df() Augmented Dickey-Fuller test in the urca package gives us a bit more information on and control over the test.
  • The ur.df() function allows us to specify whether to test stationarity around a zero-mean with no trend, around a non-zero mean with no trend, or around a trend with an intercept. This can be useful when we know that our data have no trend, for example if you have removed the trend already. ur.df() allows us to specify the lags or select them using model selection.
library(urca)
# DF tests for stock price series
x=ur.df(FPT_Data$price, type = "trend") 
summary(x)
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression trend 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -13407.2   -593.4    -74.5    571.2   7611.0 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)
## (Intercept) 184.469360 250.156936   0.737    0.461
## z.lag.1      -0.002780   0.004047  -0.687    0.492
## tt            0.322429   0.284608   1.133    0.258
## z.diff.lag    0.025841   0.034631   0.746    0.456
## 
## Residual standard error: 1430 on 841 degrees of freedom
## Multiple R-squared:  0.002157,   Adjusted R-squared:  -0.001403 
## F-statistic: 0.6059 on 3 and 841 DF,  p-value: 0.6113
## 
## 
## Value of test-statistic is: -0.6868 1.9385 0.6542 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau3 -3.96 -3.41 -3.12
## phi2  6.09  4.68  4.03
## phi3  8.27  6.25  5.34
y=ur.df(FPT_Data$price, type = "none") 
summary(y)
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression none 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 - 1 + z.diff.lag)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -13467.4   -586.5    -53.3    595.3   7606.8 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)  
## z.lag.1    0.0013053  0.0006193   2.108   0.0353 *
## z.diff.lag 0.0232973  0.0344874   0.676   0.4995  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1430 on 843 degrees of freedom
## Multiple R-squared:  0.006143,   Adjusted R-squared:  0.003785 
## F-statistic: 2.605 on 2 and 843 DF,  p-value: 0.07449
## 
## 
## Value of test-statistic is: 2.1078 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau1 -2.58 -1.95 -1.62
z=ur.df(FPT_Data$price, type = "drift") 
summary(z)
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression drift 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -13464.5   -594.0    -58.7    594.0   7631.4 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.954e+01  2.287e+02   0.304    0.761
## z.lag.1     4.529e-04  2.871e-03   0.158    0.875
## z.diff.lag  2.408e-02  3.460e-02   0.696    0.487
## 
## Residual standard error: 1431 on 842 degrees of freedom
## Multiple R-squared:  0.0006338,  Adjusted R-squared:  -0.00174 
## F-statistic: 0.267 on 2 and 842 DF,  p-value: 0.7657
## 
## 
## Value of test-statistic is: 0.1578 2.2653 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau2 -3.43 -2.86 -2.57
## phi1  6.43  4.59  3.78
  • For DF Test with Trend, test statistic (-0.6868) is greater than all critical values. Thus, we fail to reject the null hypothesis of a unit root.
  • For DF Test without drift, the test statistic (2.1078) is greater than all critical values.We fail to reject the null hypothesis of a unit root.
  • For DF Test with Drift, the test statistic (0.1578) is greater than all critical values. We fail to reject the null hypothesis of a unit root.
  • It can be seen that in all three cases of DF tests (with trend, with drift, and without drift), at significant level 1%, we can conclude that the Stock price series is non stationary.
# DF tests for 1st difference series 
library(urca)
# DF tests for stock price series
x1 =ur.df(FPT_Data$dprice, type = "trend") 
summary(x1 )
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression trend 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -13528.2   -596.9    -54.7    590.6   7651.8 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 28.74389   98.46103   0.292   0.7704    
## z.lag.1     -1.04679    0.04807 -21.778   <2e-16 ***
## tt           0.19792    0.20148   0.982   0.3262    
## z.diff.lag   0.07197    0.03437   2.094   0.0366 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1427 on 841 degrees of freedom
## Multiple R-squared:  0.4908, Adjusted R-squared:  0.489 
## F-statistic: 270.3 on 3 and 841 DF,  p-value: < 2.2e-16
## 
## 
## Value of test-statistic is: -21.7784 158.1002 237.1498 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau3 -3.96 -3.41 -3.12
## phi2  6.09  4.68  4.03
## phi3  8.27  6.25  5.34
y1 =ur.df(FPT_Data$dprice, type = "none") 
summary(y1 )
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression none 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 - 1 + z.diff.lag)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -13441.6   -484.0     48.2    703.2   7820.5 
## 
## Coefficients:
##            Estimate Std. Error t value Pr(>|t|)    
## z.lag.1    -1.03302    0.04786 -21.584   <2e-16 ***
## z.diff.lag  0.06503    0.03434   1.894   0.0586 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1431 on 843 degrees of freedom
## Multiple R-squared:  0.4871, Adjusted R-squared:  0.4859 
## F-statistic: 400.3 on 2 and 843 DF,  p-value: < 2.2e-16
## 
## 
## Value of test-statistic is: -21.5837 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau1 -2.58 -1.95 -1.62
z1 =ur.df(FPT_Data$dprice, type = "drift") 
summary(z1 )
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression drift 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -13548.5   -603.6    -62.3    597.1   7727.2 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 112.42427   49.37290   2.277   0.0230 *  
## z.lag.1      -1.04462    0.04801 -21.757   <2e-16 ***
## z.diff.lag    0.07091    0.03436   2.064   0.0393 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1427 on 842 degrees of freedom
## Multiple R-squared:  0.4903, Adjusted R-squared:  0.4891 
## F-statistic: 404.9 on 2 and 842 DF,  p-value: < 2.2e-16
## 
## 
## Value of test-statistic is: -21.7567 236.6776 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau2 -3.43 -2.86 -2.57
## phi1  6.43  4.59  3.78
  • For DF Test with Trend, the test statistic (-21.7784) is much smaller than the critical values at all levels. We reject the null hypothesis of a unit root.

  • For DF Test without Drift, the test statistic (-21.5837) is much smaller than the critical values at all levels. We reject the null hypothesis of a unit root.

  • For DF Test with Drift, the test statistic (-21.7567) is much smaller than the critical values at all levels. We reject the null hypothesis of a unit root

  • It can be seen that in all three cases of DF tests (with trend, with drift, and without drift), at significant level 1%, we can conclude that the First difference series is stationary.

  • DF test’s coefficient estimation results

    • Trend + (Intercept):28.74389 + lagged values: -1.04679*** + (trend):0.19792
    • With Drift + (Intercept): 112.42427 + lagged values: -1.04462***
    • Without Drift + lagged values: -1.03302***
# DF tests for log return series
library(urca)
# DF tests for stock price series
x2 =ur.df(FPT_Data$logret, type = "trend") 
summary(x2 )
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression trend 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.168926 -0.007490 -0.000720  0.008038  0.066127 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  1.340e-03  1.274e-03   1.051   0.2934    
## z.lag.1     -1.046e+00  4.812e-02 -21.745   <2e-16 ***
## tt           1.256e-07  2.602e-06   0.048   0.9615    
## z.diff.lag   6.779e-02  3.431e-02   1.976   0.0485 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.01845 on 841 degrees of freedom
## Multiple R-squared:  0.4923, Adjusted R-squared:  0.4905 
## F-statistic: 271.9 on 3 and 841 DF,  p-value: < 2.2e-16
## 
## 
## Value of test-statistic is: -21.7452 157.6191 236.428 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau3 -3.96 -3.41 -3.12
## phi2  6.09  4.68  4.03
## phi3  8.27  6.25  5.34
y2 =ur.df(FPT_Data$logret, type = "none") 
summary(y2 )
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression none 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 - 1 + z.diff.lag)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.167603 -0.006118  0.000700  0.009318  0.067411 
## 
## Coefficients:
##            Estimate Std. Error t value Pr(>|t|)    
## z.lag.1    -1.03567    0.04795 -21.600   <2e-16 ***
## z.diff.lag  0.06234    0.03428   1.819   0.0693 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.01848 on 843 degrees of freedom
## Multiple R-squared:  0.4894, Adjusted R-squared:  0.4882 
## F-statistic: 404.1 on 2 and 843 DF,  p-value: < 2.2e-16
## 
## 
## Value of test-statistic is: -21.5999 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau1 -2.58 -1.95 -1.62
z2 =ur.df(FPT_Data$logret, type = "drift") 
summary(z2 )
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression drift 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.168939 -0.007469 -0.000725  0.008031  0.066177 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.0013929  0.0006376   2.185   0.0292 *  
## z.lag.1     -1.0463901  0.0480920 -21.758   <2e-16 ***
## z.diff.lag   0.0677942  0.0342912   1.977   0.0484 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.01844 on 842 degrees of freedom
## Multiple R-squared:  0.4923, Adjusted R-squared:  0.4911 
## F-statistic: 408.3 on 2 and 842 DF,  p-value: < 2.2e-16
## 
## 
## Value of test-statistic is: -21.7581 236.7079 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau2 -3.43 -2.86 -2.57
## phi1  6.43  4.59  3.78
  • For DF Test with Trend, the test statistic (-21.7452) is much smaller than the critical values at all levels. We reject the null hypothesis of a unit root.

  • For DF Test without Drift, the test statistic (-21.5999 ) is much smaller than the critical values at all levels. We reject the null hypothesis of a unit root.

  • For DF Test with Drift, the test statistic (-21.7581) is much smaller than the critical values at all levels. We reject the null hypothesis of a unit root

  • It can be seen that in all three cases of DF tests (with trend, with drift, and without drift), at significant level 1%, we can conclude that the Log Return series is stationary.

  • DF test’s coefficient estimation results: * Trend: + (Intercept): 0.00134 + lagged values: -1.04679 + (trend):1.256e-07 With Drift + (Intercept): 0.0013929 + lagged values: -1.046 Without Drift + lagged values: -1.03567***

\(\to\) According to the DF test’s coefficient estimation results of First difference series and Log return series, we can conclude that both of them are stationary around value 0 (without drift)

4.2 Autocorrelation and Partial Autocorrelation (ACF & PACF)

4.2.1 ACF and PACF correlograms of 1st difference series

acf(FPT_Data$dprice, lag.max=12)

pacf(FPT_Data$dprice, lag.max=12)

  • In the ACF plot, the curve drops significantly after the lag 4 (skip lag at 0), so we should model with one moving average component MA(4) (q=4). Let’s say the PACF graph has a significant cut off after 4nd lag, and make it a AR(4) (p=4) process.

4.2.2 ACF and PACF correlograms of log return series

acf(FPT_Data$logret, lag.max=12)

pacf(FPT_Data$logret, lag.max=12)

  • In the ACF plot, the curve drops significantly after the lag 4 (skip lag at 0), so we should model with one moving average component MA(4) (q=4). Let’s say the PACF graph has a significant cut off after 4nd lag, and make it a AR(4) (p=4) process.

4.3 ARIMA Model Selection

4.3.1 Log Return Series

dmodel = arima(FPT_Data$logret, order= c(1,0,1))
library(lmtest)
library(psych)
coeftest(dmodel)
## 
## z test of coefficients:
## 
##              Estimate  Std. Error z value Pr(>|z|)  
## ar1       -0.33825359  0.34205103 -0.9889  0.32271  
## ma1        0.37184368  0.33700358  1.1034  0.26986  
## intercept  0.00136893  0.00065139  2.1016  0.03559 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(dmodel)
## [1] -4350.288
AIC(dmodel, k=log(nrow(FPT_Data)))
## [1] -4331.321
aic_table = array (NA , c (6,6,2) )
for ( ar in 0:5) {
  for ( ma in 0:5) {
    arma = arima ( FPT_Data$logret , order = c ( ar ,0, ma ) )
    aic_table [ ar +1, ma +1,1] = AIC ( arma )
    aic_table [ ar +1, ma +1,2] = AIC ( arma , k = log ( nrow ( FPT_Data ) ) )
  }
}
### AIC values
aic_table[,,1]
##           [,1]      [,2]      [,3]      [,4]      [,5]      [,6]
## [1,] -4353.218 -4351.579 -4352.822 -4351.110 -4356.516 -4355.969
## [2,] -4351.530 -4350.288 -4350.891 -4352.448 -4355.668 -4354.118
## [3,] -4353.444 -4351.458 -4362.906 -4361.108 -4355.472 -4355.380
## [4,] -4351.496 -4351.740 -4361.108 -4359.213 -4355.148 -4356.498
## [5,] -4355.215 -4354.815 -4359.109 -4354.278 -4368.271 -4353.426
## [6,] -4355.623 -4353.722 -4357.300 -4355.686 -4366.270 -4354.398
which.min (aic_table[,,1]) 
## [1] 29
### SBIC values
aic_table[,,2]
##           [,1]      [,2]      [,3]      [,4]      [,5]      [,6]
## [1,] -4343.734 -4337.354 -4333.855 -4327.401 -4328.065 -4322.777
## [2,] -4337.305 -4331.321 -4327.183 -4323.998 -4322.476 -4316.184
## [3,] -4334.477 -4327.749 -4334.456 -4327.916 -4317.538 -4312.704
## [4,] -4327.787 -4323.290 -4327.916 -4321.279 -4312.472 -4309.081
## [5,] -4326.765 -4321.623 -4321.175 -4311.602 -4320.854 -4301.267
## [6,] -4322.431 -4315.789 -4314.625 -4308.269 -4314.111 -4297.497
which.min (aic_table[,,2])
## [1] 1
arma404 = arima(FPT_Data$logret, order=c(4,0,4))
coeftest(arma404)
## 
## z test of coefficients:
## 
##              Estimate  Std. Error z value  Pr(>|z|)    
## ar1        0.35508619  0.10809950  3.2848 0.0010205 ** 
## ar2        0.58998821  0.12877878  4.5814 4.619e-06 ***
## ar3        0.13680535  0.12374173  1.1056 0.2689120    
## ar4       -0.59973996  0.10360104 -5.7889 7.083e-09 ***
## ma1       -0.34168643  0.09148469 -3.7349 0.0001878 ***
## ma2       -0.66430991  0.11043467 -6.0154 1.794e-09 ***
## ma3       -0.16024917  0.10491256 -1.5275 0.1266480    
## ma4        0.74970188  0.08735192  8.5825 < 2.2e-16 ***
## intercept  0.00136921  0.00070265  1.9486 0.0513392 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
arma202 = arima(FPT_Data$logret, order=c(2,0,2))
coeftest(arma202)
## 
## z test of coefficients:
## 
##              Estimate  Std. Error  z value Pr(>|z|)    
## ar1       -0.50785414  0.05824391  -8.7194  < 2e-16 ***
## ar2       -0.92166516  0.04277899 -21.5448  < 2e-16 ***
## ma1        0.54538995  0.06701318   8.1385    4e-16 ***
## ma2        0.89094397  0.05496018  16.2107  < 2e-16 ***
## intercept  0.00136144  0.00063101   2.1575  0.03096 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
arma402 = arima(FPT_Data$logret, order=c(4,0,2))
coeftest(arma402)
## 
## z test of coefficients:
## 
##              Estimate  Std. Error  z value  Pr(>|z|)    
## ar1       -0.53083573  0.07741768  -6.8568 7.043e-12 ***
## ar2       -0.92648213  0.07281527 -12.7237 < 2.2e-16 ***
## ar3       -0.01735194  0.04335882  -0.4002   0.68901    
## ar4       -0.00023504  0.03951633  -0.0059   0.99525    
## ma1        0.55558365  0.06930234   8.0168 1.085e-15 ***
## ma2        0.88860187  0.06244953  14.2291 < 2.2e-16 ***
## intercept  0.00136309  0.00062140   2.1936   0.02827 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
arma204 = arima(FPT_Data$logret, order=c(2,0,4))
coeftest(arma204)
## 
## z test of coefficients:
## 
##              Estimate  Std. Error z value Pr(>|z|)  
## ar1       -0.72829250  0.56752359 -1.2833  0.19939  
## ar2       -0.35571918  0.27603165 -1.2887  0.19751  
## ma1        0.75500323  0.56601721  1.3339  0.18224  
## ma2        0.31472876  0.29298399  1.0742  0.28272  
## ma3       -0.06068002  0.06056135 -1.0020  0.31636  
## ma4        0.05229458  0.06816214  0.7672  0.44296  
## intercept  0.00135901  0.00062373  2.1788  0.02934 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

4.4 Diagnostic Checking

4.4.1 Residual Analysis

#for log returns
arma404 = arima(FPT_Data$logret, order=c(4,0,4))
checkresiduals(arma404)

## 
##  Ljung-Box test
## 
## data:  Residuals from ARIMA(4,0,4) with non-zero mean
## Q* = 11.898, df = 3, p-value = 0.007741
## 
## Model df: 8.   Total lags used: 11
Box.test(arma404$residuals, lag =12, type="Ljung-Box")
## 
##  Box-Ljung test
## 
## data:  arma404$residuals
## X-squared = 14.872, df = 12, p-value = 0.2485
arma202 = arima(FPT_Data$logret, order=c(2,0,2))
checkresiduals(arma202)

## 
##  Ljung-Box test
## 
## data:  Residuals from ARIMA(2,0,2) with non-zero mean
## Q* = 23.927, df = 6, p-value = 0.0005387
## 
## Model df: 4.   Total lags used: 10
Box.test(arma202$residuals, lag =12, type="Ljung-Box")
## 
##  Box-Ljung test
## 
## data:  arma202$residuals
## X-squared = 26.063, df = 12, p-value = 0.01051

4.4.2 Stationary property by unit circle

autoplot(arma404)

autoplot(arma202)

4.5 Forecasting

accuracy(arma404)
##                         ME       RMSE        MAE MPE MAPE      MASE
## Training set -1.164533e-05 0.01813996 0.01210598 NaN  Inf 0.6822612
##                      ACF1
## Training set -0.001012526
forecast_value = forecast(arma404, h = 20)
summary(forecast_value)
## 
## Forecast method: ARIMA(4,0,4) with non-zero mean
## 
## Model Information:
## 
## Call:
## arima(x = FPT_Data$logret, order = c(4, 0, 4))
## 
## Coefficients:
##          ar1     ar2     ar3      ar4      ma1      ma2      ma3     ma4
##       0.3551  0.5900  0.1368  -0.5997  -0.3417  -0.6643  -0.1602  0.7497
## s.e.  0.1081  0.1288  0.1237   0.1036   0.0915   0.1104   0.1049  0.0874
##       intercept
##          0.0014
## s.e.     0.0007
## 
## sigma^2 estimated as 0.0003291:  log likelihood = 2194.14,  aic = -4368.27
## 
## Error measures:
##                         ME       RMSE        MAE MPE MAPE      MASE
## Training set -1.164533e-05 0.01813996 0.01210598 NaN  Inf 0.6822612
##                      ACF1
## Training set -0.001012526
## 
## Forecasts:
##     Point Forecast       Lo 80      Hi 80       Lo 95      Hi 95
## 848   0.0040763416 -0.01917096 0.02732364 -0.03147733 0.03963001
## 849  -0.0029711547 -0.02622054 0.02027823 -0.03852802 0.03258571
## 850   0.0016655042 -0.02164005 0.02497106 -0.03397727 0.03730828
## 851  -0.0029432526 -0.02626758 0.02038107 -0.03861473 0.03272822
## 852  -0.0022046335 -0.02563652 0.02122725 -0.03804061 0.03363134
## 853   0.0001995127 -0.02323294 0.02363197 -0.03563734 0.03603636
## 854  -0.0019223239 -0.02544931 0.02160466 -0.03790374 0.03405909
## 855   0.0016077618 -0.02196823 0.02518375 -0.03444860 0.03766413
## 856   0.0014953086 -0.02208434 0.02507496 -0.03456665 0.03755727
## 857   0.0018059458 -0.02181704 0.02542893 -0.03432229 0.03793418
## 858   0.0036053875 -0.02001954 0.02723031 -0.03252582 0.03973659
## 859   0.0022950991 -0.02133012 0.02592032 -0.03383656 0.03842676
## 860   0.0030014227 -0.02062539 0.02662823 -0.03313266 0.03913551
## 861   0.0025390454 -0.02111181 0.02618990 -0.03363182 0.03870991
## 862   0.0015331326 -0.02212069 0.02518696 -0.03464227 0.03770853
## 863   0.0017856109 -0.02187944 0.02545066 -0.03440696 0.03797818
## 864   0.0007949196 -0.02287463 0.02446446 -0.03540453 0.03699436
## 865   0.0007317899 -0.02293776 0.02440134 -0.03546766 0.03693124
## 866   0.0007627037 -0.02290731 0.02443272 -0.03543746 0.03696287
## 867   0.0004494818 -0.02322267 0.02412163 -0.03575394 0.03665291
plot(forecast_value)