1 Simulating ARCH(1)

Now you have to simulate 2 ARCH(1) models using 500 periods (days) with the following specifications:

For model 1 use β0=0, α0=1, and α1=0.90. You can do this simulation in R as follows:

alpha0=1
alpha1= 0.9
B0= 0

I create empty vectors for the 500 variances and shocks: I will simulate 2-years of daily returns of a financial instrument with mean 0

n = 500
error = single(n)
h = single(n)

The single function creates a numeric vector with zero values.

I generate the first random shock following the specifications:

I define the values for variance and shcok for day 1

h[1] = alpha0 + alpha1*0 
# Since there is no shock at day 0, I will assign 0 to this shock, so I only
#   consider alpha for the formula of the variance

error[1] = rnorm(n = 1, mean=0, sd=sqrt(h[1]))

Now create the Y variable, which will be an ARCH(1) process. Assign the value for Y for the first day:

Y= single(length=n)
Y[1]= B0 + error[1]

Now fill out the Y values for the rest of the days

for (i in 2:n){
  h[i] <- alpha0 + alpha1*((error[i-1]^2))
  error[i] <- rnorm(n=1, 0, sqrt(h[i]))
}

We can see the first values of h and error:

head(error)
## [1] -0.43589634 -1.12637398 -0.07566626 -1.15060642 -1.83322790 -1.36678642
head(h)
## [1] 1.000000 1.171005 2.141846 1.005153 2.191506 4.024652

Now I create the Y values from day 2 to day 500:

for (i in 2:n){
Y[i] <- B0 + error[i]
}
plot(Y,  type="l", col="blue")

Now using the same dataset SIMULATE model 2 (as Y2) as another ARCH(1). Use alpha0 = 0.1 and alpha1=0.1

alpha0_2 = 0.1
alpha1_2 = 0.1
B0_2 = 0
n_2 = 500
error_2 <- single(n_2)
h_2 <- single(n_2)
h_2[1] = alpha0_2 + alpha1_2*0
error_2[1] = rnorm(n = 1, mean = 0, sd=sqrt(h[1]))
Y2 = single(length=n_2)
Y2[1] = B0_2 + error_2[1]
for (i in 2:n_2){
  h_2[i] <- alpha0_2 + alpha1_2*((error_2[i-1]^2))
  error_2[i] <- rnorm(n=1, 0, sqrt(h_2[i]))
}
for (i in 2:n_2){
Y2[i] <- B0_2 + error_2[i]
}
plot(Y2,  type="l", col="red")

WHAT IS THE DIFFERENCE BETWEEN THE SERIES Y AND Y2?

I CAN EASILY SAY THAT THE VOLATILITY IS GREATER IN THE FIRST GRAPH, ALSO THE VALUES TEND TO GO FROM BIGGER VALUES, IN THE SECOND GRAPH WE CAN SEE THAT IT ONLY LOVES BETWEEN 1 AND -1 , NEVERTHELESS IN THE FIRST IT VARIATES BETWEEN -40 AND OVER 40. APPARENTLY THE SMALLER THE ALPHA, SMALLER THE VOLATILITY.

Looking at the original ARCH equation, EXPLAIN why do you think both series are different?

THE ALPHA VALUES

2 Further understanding of volatility

In this exercise we analyze volatility of financial returns using rolling windows. It has been shown that volatility of financial instruments changeS over time. As we practiced in previous exercise, family ARCH models are designed to model the changing volatility, which is the standard deviation of returns (actually, these models analyze the changing variance, but the volatility is the squared root of the variance). In this part, we will use daily returns of a market index, and calculate rolling means and rolling standard deviations using a moving/rolling windows of 20 business days.

2.1 Download daily returns of IP&C (Jan 2008 to date)

#Load the quantmod library to use the getsymbols command:
library(quantmod)
## Warning: package 'quantmod' was built under R version 4.0.3
## Loading required package: xts
## Loading required package: zoo
## Warning: package 'zoo' was built under R version 4.0.3
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## Loading required package: TTR
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo

Get Data

IPC <- getSymbols("^MXX", from="2008-01-01",auto.assign = FALSE)[,6]
## 'getSymbols' currently uses auto.assign=TRUE by default, but will
## use auto.assign=FALSE in 0.5-0. You will still be able to use
## 'loadSymbols' to automatically load data. getOption("getSymbols.env")
## and getOption("getSymbols.auto.assign") will still be checked for
## alternate defaults.
## 
## This message is shown once per session and may be disabled by setting 
## options("getSymbols.warning4.0"=FALSE). See ?getSymbols for details.
## Warning: ^MXX contains missing values. Some functions will not work if objects
## contain missing values in the middle of the series. Consider using na.omit(),
## na.approx(), na.fill(), etc to remove or replace them.
# auto.assign=FALSE since I want the dataset to be called IPC, not MXX
# I indicate to get the column 6 of the dataset, which is the adjusted price

# I calculate cc returns of the IPCyC index:

ipc_ret <- na.omit(diff(log(IPC)))

2.2 Using the rollapply() function from the zoo package, and a moving window of 20 business days (one month), generate a dataset with the rolling mean and rolling volatility of the IPyC continuously compounded returns:

library(zoo)
roll_mean <- na.omit(rollapply(ipc_ret, 20, mean))
roll_sd <- na.omit(rollapply(ipc_ret, 20, sd))

ipc_mean_vol <- merge(roll_mean, roll_sd)
colnames(ipc_mean_vol) <- c("roll_mean", "roll_sd")

2.3 R will generate a new dataset that contains one time window for each row. Now plot both variables. The average 20-day volatility and the average 20-day returns: (The sd will be the red line and the mean, the black line):

plot(ipc_mean_vol)

WHAT DO YOU OBSERVE? In which periods you observe more volatility? Describe with your words, if you see a relationship between volatility and average returns.

THE VOLATILITY OF IPC IS HETEROSCEDASTICITY, IN SOME DATES IT INCREASES SUCH AS 2008-2009 DUE TO THE CRISIS AND THE FIRST SEMESTER OF 2019. THE VOLATILIY OF THE RETURNS OF THE IPC IS STRONGLY CORRELATED WITH THE RETURNS IN A WAY IN WHICH AN INVESTOR WOULDN’T INVEST IN A DECREASING MARKET, SO THIS LEAD TO A FALL IN PRICES.I GUESS THAT IF WE GRAPH THE VALUES FROM 2020 AND 2021, THERE SHOULD BE A HIKE DUE TO COVID 19.

2.4 Do the same steps 2 and 3, but now move the window to 5 days.

roll_mean <- na.omit(rollapply(ipc_ret, 5, mean))
roll_sd <- na.omit(rollapply(ipc_ret, 5, sd))

ipc_mean_vol <- merge(roll_mean, roll_sd)
colnames(ipc_mean_vol) <- c("roll_mean", "roll_sd")
plot(ipc_mean_vol)

Report your responses to the same questions and compare the results with the 20-day window results.

THE VOLATILITY OF 5 DAYS IS HIGHER, WE CAN SEE THIS BY CHECKING THE THE VALUES IN THE SECOND WINDOW GOES FROM -0.04 TO 0.06.

3 Modeling the IPCyC returns with an ARCH model

3.1 Download daily data of the IPyC from Yahoo Finance from Jan 1, 2013 to date. Check whether the IPCyC cc returns are heteroscedastic. In other words, check whether the IPCyC returns follow an ARCH(1) process.

IPC13 <- getSymbols("^MXX", from="2013-01-01",auto.assign = FALSE)[,6]
## Warning: ^MXX contains missing values. Some functions will not work if objects
## contain missing values in the middle of the series. Consider using na.omit(),
## na.approx(), na.fill(), etc to remove or replace them.
# I calculate cc returns:
ipc_ret13 <- na.omit(diff(log(IPC13)))

colnames(ipc_ret13) <- c("r")

Now we check whether the IPCyC returns are heteroscedastic. You can do this by testing whether the cc IPCyC returns follows an ARCH process. Do this test and interpret it.

We do this test with the ArchTest function from the FinTS package. Install this package first:

#install.packages("FinTS")
library(FinTS)
## Warning: package 'FinTS' was built under R version 4.0.5
ArchTest(ipc_ret13$r)
## 
##  ARCH LM-test; Null hypothesis: no ARCH effects
## 
## data:  ipc_ret13$r
## Chi-squared = 436.93, df = 12, p-value < 2.2e-16

INTERPRETATION:

Since the p-value of this test is less than 0.05, we can reject the NULL hypothesis that states that there is NO ARCH effects. In sum, we can have statistical evidence to say that the IPCyC returns has heteroscedasticity in its variance.

3.2 Check if an ARCH(1) model fits the series We need to install the fGarch package first

library(fGarch)
## Warning: package 'fGarch' was built under R version 4.0.5
## Loading required package: timeDate
## Loading required package: timeSeries
## 
## Attaching package: 'timeSeries'
## The following object is masked from 'package:zoo':
## 
##     time<-
## Loading required package: fBasics
## Warning: package 'fBasics' was built under R version 4.0.5
## 
## Attaching package: 'fBasics'
## The following object is masked from 'package:TTR':
## 
##     volatility
arch.fit <- garchFit(~garch(1,0), data = ipc_ret13$r, trace = F)
## Warning: Using formula(x) is deprecated when x is a character vector of length > 1.
##   Consider formula(paste(x, collapse = " ")) instead.
summary(arch.fit)
## 
## Title:
##  GARCH Modelling 
## 
## Call:
##  garchFit(formula = ~garch(1, 0), data = ipc_ret13$r, trace = F) 
## 
## Mean and Variance Equation:
##  data ~ garch(1, 0)
## <environment: 0x00000000226d60a0>
##  [data = ipc_ret13$r]
## 
## Conditional Distribution:
##  norm 
## 
## Coefficient(s):
##         mu       omega      alpha1  
## 3.5403e-05  6.7796e-05  3.1755e-01  
## 
## Std. Errors:
##  based on Hessian 
## 
## Error Analysis:
##         Estimate  Std. Error  t value Pr(>|t|)    
## mu     3.540e-05   1.981e-04    0.179    0.858    
## omega  6.780e-05   2.895e-06   23.417  < 2e-16 ***
## alpha1 3.175e-01   3.934e-02    8.072 6.66e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Log Likelihood:
##  6744.625    normalized:  3.244168 
## 
## Description:
##  Thu Apr 22 14:28:39 2021 by user: MontseG 
## 
## 
## Standardised Residuals Tests:
##                                 Statistic p-Value    
##  Jarque-Bera Test   R    Chi^2  560.1164  0          
##  Shapiro-Wilk Test  R    W      0.9770357 0          
##  Ljung-Box Test     R    Q(10)  27.6887   0.002024357
##  Ljung-Box Test     R    Q(15)  31.74176  0.006979723
##  Ljung-Box Test     R    Q(20)  41.03394  0.003688027
##  Ljung-Box Test     R^2  Q(10)  228.9894  0          
##  Ljung-Box Test     R^2  Q(15)  365.039   0          
##  Ljung-Box Test     R^2  Q(20)  418.5958  0          
##  LM Arch Test       R    TR^2   194.1093  0          
## 
## Information Criterion Statistics:
##       AIC       BIC       SIC      HQIC 
## -6.485449 -6.477311 -6.485454 -6.482467

We can also run the same ARCH model using the ugarchfit from the rugarch package

library(FinTS)
library(rugarch)
## Warning: package 'rugarch' was built under R version 4.0.5
## Loading required package: parallel
## 
## Attaching package: 'rugarch'
## The following object is masked from 'package:stats':
## 
##     sigma
#ARCH(1) 

Espec1=ugarchspec(variance.model= list(model= "sGARCH", garchOrder= c(1, 0), 
                                       
submodel= NULL, external.regressors= NULL, variance.targeting= FALSE), 
mean.model= list(armaOrder= c(0, 0), include.mean= TRUE, archm= FALSE, 
archpow= 0, arfima= FALSE, external.regressors= NULL, archex= FALSE), 
distribution.model= "norm", start.pars= list(), fixed.pars= list())

#Running the ARCH model with the specifications:
arch1<- ugarchfit(spec=Espec1, data=ipc_ret13$r)
arch1
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : sGARCH(1,0)
## Mean Model   : ARFIMA(0,0,0)
## Distribution : norm 
## 
## Optimal Parameters
## ------------------------------------
##         Estimate  Std. Error  t value Pr(>|t|)
## mu      0.000035    0.000198  0.17857  0.85828
## omega   0.000068    0.000003 23.40725  0.00000
## alpha1  0.318060    0.039408  8.07096  0.00000
## 
## Robust Standard Errors:
##         Estimate  Std. Error  t value Pr(>|t|)
## mu      0.000035    0.000205  0.17275 0.862850
## omega   0.000068    0.000005 12.82390 0.000000
## alpha1  0.318060    0.079350  4.00831 0.000061
## 
## LogLikelihood : 6744.631 
## 
## Information Criteria
## ------------------------------------
##                     
## Akaike       -6.4855
## Bayes        -6.4773
## Shibata      -6.4855
## Hannan-Quinn -6.4825
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                         statistic   p-value
## Lag[1]                      9.982 0.0015810
## Lag[2*(p+q)+(p+q)-1][2]    10.633 0.0013001
## Lag[4*(p+q)+(p+q)-1][5]    14.918 0.0004676
## d.o.f=0
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                         statistic   p-value
## Lag[1]                      1.856 0.1731437
## Lag[2*(p+q)+(p+q)-1][2]    15.529 0.0000666
## Lag[4*(p+q)+(p+q)-1][5]    68.035 0.0000000
## d.o.f=1
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale   P-Value
## ARCH Lag[2]     27.29 0.500 2.000 1.747e-07
## ARCH Lag[4]     78.14 1.397 1.611 0.000e+00
## ARCH Lag[6]    101.12 2.222 1.500 0.000e+00
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  3.0645
## Individual Statistics:              
## mu     0.07035
## omega  2.44688
## alpha1 1.40735
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          0.846 1.01 1.35
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                    t-value   prob sig
## Sign Bias           0.6489 0.5165    
## Negative Sign Bias  0.6613 0.5085    
## Positive Sign Bias  0.9185 0.3585    
## Joint Effect        1.3397 0.7197    
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     69.50    1.112e-07
## 2    30     77.03    3.123e-06
## 3    40     93.68    2.141e-06
## 4    50    108.57    2.119e-06
## 
## 
## Elapsed time : 0.3002679

Both functions get the same estimations for the ARCH coefficients.

INTERPRET the OUTPUT of the ARCH(1) model. You have to interpret the omega, alpha and mu coefficients. The omega coefficient is equivalent to the α0 coefficient of our model, and the mu coefficient is actually our β0 coefficient.

THE BETA0 (MU/MEAN OVER TIME) IS NOT SIGNIFICANT. THE ALPHA 0 (OMEGA/ CONSTANT) IS STADISTICALLY SIGNIFICANT. ALPHA1 IS 0.318060 WHICH MEANS THAT ERRORS OF YESTERDAY AFECT 31.8060% THE VARIANCE OF RANDOM SHOCKS

IF WE PLOT THE VARIABLE WE CAN SEE THE HETEROSCEDASTICITY

plot(ipc_ret13$r)

3.3 Check if a GARCH(1,1) fits the series. Run the model :

garch.fit <- garchFit(~garch(1,1), data = ipc_ret13$r, trace = F)
## Warning: Using formula(x) is deprecated when x is a character vector of length > 1.
##   Consider formula(paste(x, collapse = " ")) instead.
summary(garch.fit)
## 
## Title:
##  GARCH Modelling 
## 
## Call:
##  garchFit(formula = ~garch(1, 1), data = ipc_ret13$r, trace = F) 
## 
## Mean and Variance Equation:
##  data ~ garch(1, 1)
## <environment: 0x000000002b9e8558>
##  [data = ipc_ret13$r]
## 
## Conditional Distribution:
##  norm 
## 
## Coefficient(s):
##         mu       omega      alpha1       beta1  
## 1.5569e-04  2.9886e-06  1.0941e-01  8.6024e-01  
## 
## Std. Errors:
##  based on Hessian 
## 
## Error Analysis:
##         Estimate  Std. Error  t value Pr(>|t|)    
## mu     1.557e-04   1.754e-04    0.887 0.374864    
## omega  2.989e-06   8.075e-07    3.701 0.000215 ***
## alpha1 1.094e-01   1.567e-02    6.981 2.93e-12 ***
## beta1  8.602e-01   2.025e-02   42.474  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Log Likelihood:
##  6872.89    normalized:  3.305863 
## 
## Description:
##  Thu Apr 22 14:28:45 2021 by user: MontseG 
## 
## 
## Standardised Residuals Tests:
##                                 Statistic p-Value     
##  Jarque-Bera Test   R    Chi^2  89.42055  0           
##  Shapiro-Wilk Test  R    W      0.9914477 1.040131e-09
##  Ljung-Box Test     R    Q(10)  23.27291  0.009782818 
##  Ljung-Box Test     R    Q(15)  26.32573  0.03473515  
##  Ljung-Box Test     R    Q(20)  35.18153  0.0191585   
##  Ljung-Box Test     R^2  Q(10)  24.2778   0.006896192 
##  Ljung-Box Test     R^2  Q(15)  27.23148  0.02690594  
##  Ljung-Box Test     R^2  Q(20)  32.06671  0.04259263  
##  LM Arch Test       R    TR^2   25.53685  0.01247407  
## 
## Information Criterion Statistics:
##       AIC       BIC       SIC      HQIC 
## -6.607879 -6.597028 -6.607886 -6.603903

We can also run the same model using the other function:

#ARCH(1) 

Espec2=ugarchspec(variance.model= list(model= "sGARCH", garchOrder= c(1, 1), 
submodel= NULL, external.regressors= NULL, variance.targeting= FALSE), 
mean.model= list(armaOrder= c(0, 0), include.mean= TRUE, archm= FALSE, 
archpow= 0, arfima= FALSE, external.regressors= NULL, archex= FALSE), 
distribution.model= "norm", start.pars= list(), fixed.pars= list())

#Estimación del GARCH(1,1) 
garch1<- ugarchfit(spec=Espec2, data=ipc_ret13$r)
garch1
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : sGARCH(1,1)
## Mean Model   : ARFIMA(0,0,0)
## Distribution : norm 
## 
## Optimal Parameters
## ------------------------------------
##         Estimate  Std. Error  t value Pr(>|t|)
## mu      0.000153    0.000176  0.86904 0.384824
## omega   0.000003    0.000002  1.68729 0.091547
## alpha1  0.109276    0.014713  7.42725 0.000000
## beta1   0.860910    0.019430 44.30748 0.000000
## 
## Robust Standard Errors:
##         Estimate  Std. Error  t value Pr(>|t|)
## mu      0.000153    0.000161  0.94951 0.342360
## omega   0.000003    0.000008  0.35645 0.721501
## alpha1  0.109276    0.028522  3.83130 0.000127
## beta1   0.860910    0.070150 12.27245 0.000000
## 
## LogLikelihood : 6872.89 
## 
## Information Criteria
## ------------------------------------
##                     
## Akaike       -6.6079
## Bayes        -6.5970
## Shibata      -6.6079
## Hannan-Quinn -6.6039
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                         statistic  p-value
## Lag[1]                      10.38 0.001275
## Lag[2*(p+q)+(p+q)-1][2]     10.61 0.001315
## Lag[4*(p+q)+(p+q)-1][5]     13.64 0.001026
## d.o.f=0
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                         statistic p-value
## Lag[1]                    0.06162 0.80396
## Lag[2*(p+q)+(p+q)-1][5]   3.37750 0.34242
## Lag[4*(p+q)+(p+q)-1][9]   9.20133 0.07388
## d.o.f=2
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale P-Value
## ARCH Lag[3]     3.896 0.500 2.000 0.04841
## ARCH Lag[5]     6.084 1.440 1.667 0.05741
## ARCH Lag[7]    10.854 2.315 1.543 0.01161
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  9.8344
## Individual Statistics:              
## mu     0.04325
## omega  2.11537
## alpha1 0.25663
## beta1  0.21859
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          1.07 1.24 1.6
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                    t-value   prob sig
## Sign Bias           0.3725 0.7095    
## Negative Sign Bias  1.1168 0.2642    
## Positive Sign Bias  0.7319 0.4643    
## Joint Effect        2.4495 0.4845    
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     40.53    2.787e-03
## 2    30     54.55    2.795e-03
## 3    40     80.75    9.714e-05
## 4    50     95.63    7.635e-05
## 
## 
## Elapsed time : 0.2994981

*INTERPRET the model output**. What does each coefficient mean?

THE BETA0 (MU/MEAN OVER TIME) IS NOT SIGNIFICANT. THE ALPHA 0 (OMEGA/ CONSTANT) IS STADISTICALLY SIGNIFICANT. ALPHA1 IS 0.109276 WHICH MEANS THAT ERRORS OF YESTERDAY AFECT 10.9726% THE VARIANCE OF RANDOM SHOCKS. THE BETA1 REPRESENTS A POSITIVE AND SIGNIFICANT RELATIONSHIP WHEN MU, OMEGA AND ALPHA1 ARE 0

3.4 Do a forecast of the volatility of 5 days in the future, and do a graph to show this prediction. To do this, run the following:

predict(garch.fit, n.ahead=5, plot=TRUE)

4 Estimating the market model under heterogeneity of varinca

4.1 Download the daily returns of CEMEX and the IPCyC (from Jan 2015 to date) from Yahoo finance. Save the variable as datacemex.

getSymbols("CEMEXCPO.MX", periodicity= "daily",from = "2015-01-01")
## [1] "CEMEXCPO.MX"
getSymbols("^MXX", periodicity= "daily",from = "2015-01-01")
## [1] "^MXX"
datacemex <- merge(CEMEXCPO.MX$CEMEXCPO.MX.Adjusted, MXX$MXX.Adjusted)

4.2 Run a simple market model to estimate a beta coefficient of CEMEX. As comments, adequately interpret the beta coefficient, the Jensen alpha coefficient, and their p-values.

datacemex$stockreturns <- log(datacemex$CEMEXCPO.MX.Adjusted /(lag(datacemex$CEMEXCPO.MX.Adjusted,1)))
datacemex$ipc_returns <- diff(log(datacemex$MXX.Adjusted))
datacemex$stockreturs2 <- diff(log(datacemex$CEMEXCPO.MX.Adjusted))
m1 <- lm(datacemex$stockreturns ~ datacemex$ipc_returns)
summary(m1)
## 
## Call:
## lm(formula = datacemex$stockreturns ~ datacemex$ipc_returns)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.089845 -0.010198 -0.000743  0.009071  0.112412 
## 
## Coefficients:
##                         Estimate Std. Error t value Pr(>|t|)    
## (Intercept)           -3.975e-05  4.741e-04  -0.084    0.933    
## datacemex$ipc_returns  1.463e+00  4.687e-02  31.223   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.01885 on 1579 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.3817, Adjusted R-squared:  0.3813 
## F-statistic: 974.9 on 1 and 1579 DF,  p-value: < 2.2e-16

THE DEPENDANT VARIABLE OF THIS MODEL IS THE DAILY STOCK RETURN OF CEMEX AND THE INDEPENDENT VARIABLE IS THE MEXICAN MARKET. BASED ON THE COEFFICIENTS WE CAN SAY THAT WHEN IPC RETURNS MOVE IN 1 CEMEX WOULD MOVE IN 1.463. WHICH RERPESENTS A POSITIVE RELATIONSHIP BETWEEN THE VARIABLES.

4.3 The OLS regression method you used in the previous point is adequate when we assume no autocorrelation of errors and also homogeneity of variance is assumed for any OLS regresson model. If these assumptions do not hold then the OLS coefficients might be accurate but its standard error will not be reliable. You have to examine the data to check for both autocorrelation and heterogeneity of variance. Do the following:

4.4 Check evidence for homogeneity of error variance in the market model. Do the corresponding test and interpret it. (test whether the residuals of the regression follows an ARCH process)

datacemex$residuals <- m1$residuals
ArchTest(datacemex$residuals)
## 
##  ARCH LM-test; Null hypothesis: no ARCH effects
## 
## data:  datacemex$residuals
## Chi-squared = 97.271, df = 12, p-value = 1.903e-15

INTERPRETATION

DUE TO THE PVALUE SMALLER THAN 0.05, WE CAN REJECT THE NUL HYPOTHESIS. ALSO WE HAVE ENOUGH STATISTICAL EVIDENCE TO SAY THAT THERE’S HETERISCEDASTICITY IN THE MODEL.

4.5 Run a market model with ARCH / GARCH effects:

4.6 Run an ARCH(5) market model (hint: use the ugarchfit function including the market returns as external regressor)

datacemex <- na.omit(datacemex)

Espec3=ugarchspec(variance.model= list(model= "sGARCH", garchOrder= c(5, 0), 
submodel= NULL, external.regressors= NULL, variance.targeting= FALSE), 
mean.model= list(armaOrder= c(0, 0), include.mean= TRUE, archm= FALSE, 
archpow= 0, arfima= FALSE, external.regressors= datacemex$ipc_returns, archex= FALSE), 
distribution.model= "norm", start.pars= list(), fixed.pars= list())

#Estimación del GARCH(1,1) 
arch2<- ugarchfit(spec=Espec3, data=datacemex$stockreturns)
arch2
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : sGARCH(5,0)
## Mean Model   : ARFIMA(0,0,0)
## Distribution : norm 
## 
## Optimal Parameters
## ------------------------------------
##         Estimate  Std. Error  t value Pr(>|t|)
## mu     -0.000411    0.000427 -0.96124 0.336431
## mxreg1  1.462400    0.048486 30.16134 0.000000
## omega   0.000205    0.000016 12.95602 0.000000
## alpha1  0.164313    0.033264  4.93968 0.000001
## alpha2  0.108845    0.032700  3.32864 0.000873
## alpha3  0.104770    0.037648  2.78290 0.005388
## alpha4  0.044250    0.026640  1.66102 0.096709
## alpha5  0.026766    0.025528  1.04848 0.294420
## 
## Robust Standard Errors:
##         Estimate  Std. Error  t value Pr(>|t|)
## mu     -0.000411    0.000451 -0.91076 0.362421
## mxreg1  1.462400    0.060149 24.31302 0.000000
## omega   0.000205    0.000031  6.65926 0.000000
## alpha1  0.164313    0.045216  3.63394 0.000279
## alpha2  0.108845    0.047361  2.29822 0.021549
## alpha3  0.104770    0.054017  1.93958 0.052431
## alpha4  0.044250    0.038116  1.16094 0.245665
## alpha5  0.026766    0.042306  0.63268 0.526943
## 
## LogLikelihood : 4097.379 
## 
## Information Criteria
## ------------------------------------
##                     
## Akaike       -5.1764
## Bayes        -5.1493
## Shibata      -5.1765
## Hannan-Quinn -5.1663
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                         statistic p-value
## Lag[1]                    0.03163  0.8588
## Lag[2*(p+q)+(p+q)-1][2]   0.88616  0.5367
## Lag[4*(p+q)+(p+q)-1][5]   1.83536  0.6578
## d.o.f=0
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                          statistic  p-value
## Lag[1]                      0.1475 0.700921
## Lag[2*(p+q)+(p+q)-1][14]   13.7866 0.043241
## Lag[4*(p+q)+(p+q)-1][24]   26.5308 0.003375
## d.o.f=5
## 
## Weighted ARCH LM Tests
## ------------------------------------
##              Statistic Shape Scale   P-Value
## ARCH Lag[6]     0.1491 0.500 2.000 0.6994108
## ARCH Lag[8]     0.1812 1.480 1.774 0.9754601
## ARCH Lag[10]   18.7933 2.424 1.650 0.0003235
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  3.3593
## Individual Statistics:             
## mu     0.0926
## mxreg1 0.2257
## omega  1.2938
## alpha1 0.2277
## alpha2 0.7692
## alpha3 0.2632
## alpha4 0.8815
## alpha5 1.3010
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          1.89 2.11 2.59
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                     t-value   prob sig
## Sign Bias          0.778217 0.4366    
## Negative Sign Bias 0.007138 0.9943    
## Positive Sign Bias 0.573448 0.5664    
## Joint Effect       0.841823 0.8394    
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     89.54    3.995e-11
## 2    30    106.19    9.768e-11
## 3    40    116.15    1.351e-09
## 4    50    134.81    6.047e-10
## 
## 
## Elapsed time : 0.8645699

4.6.1 Run a GARCH(1,1) market model:

Espec4=ugarchspec(variance.model= list(model= "sGARCH", garchOrder= c(1, 1), 
submodel= NULL, external.regressors= NULL, variance.targeting= FALSE), 
mean.model= list(armaOrder= c(0, 0), include.mean= TRUE, archm= FALSE, 
archpow= 0, arfima= FALSE, external.regressors= datacemex$ipc_returns, archex= FALSE), 
distribution.model= "norm", start.pars= list(), fixed.pars= list())

#Estimación del GARCH(1,1) 
garch2<- ugarchfit(spec=Espec4, data=datacemex$stockreturns)
garch2
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : sGARCH(1,1)
## Mean Model   : ARFIMA(0,0,0)
## Distribution : norm 
## 
## Optimal Parameters
## ------------------------------------
##         Estimate  Std. Error   t value Pr(>|t|)
## mu     -0.000287    0.000416  -0.69028 0.490020
## mxreg1  1.449538    0.049458  29.30841 0.000000
## omega   0.000006    0.000002   3.94861 0.000079
## alpha1  0.051789    0.006121   8.46033 0.000000
## beta1   0.930769    0.007827 118.91390 0.000000
## 
## Robust Standard Errors:
##         Estimate  Std. Error  t value Pr(>|t|)
## mu     -0.000287    0.000406 -0.70834 0.478732
## mxreg1  1.449538    0.069002 21.00732 0.000000
## omega   0.000006    0.000004  1.81286 0.069854
## alpha1  0.051789    0.008424  6.14762 0.000000
## beta1   0.930769    0.012015 77.46517 0.000000
## 
## LogLikelihood : 4124.396 
## 
## Information Criteria
## ------------------------------------
##                     
## Akaike       -5.2144
## Bayes        -5.1974
## Shibata      -5.2144
## Hannan-Quinn -5.2081
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                         statistic p-value
## Lag[1]                    0.02293  0.8796
## Lag[2*(p+q)+(p+q)-1][2]   0.43870  0.7231
## Lag[4*(p+q)+(p+q)-1][5]   1.94358  0.6318
## d.o.f=0
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                         statistic p-value
## Lag[1]                      6.219 0.01264
## Lag[2*(p+q)+(p+q)-1][5]     6.836 0.05684
## Lag[4*(p+q)+(p+q)-1][9]     9.234 0.07273
## d.o.f=2
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale P-Value
## ARCH Lag[3] 0.0001112 0.500 2.000  0.9916
## ARCH Lag[5] 1.7496827 1.440 1.667  0.5292
## ARCH Lag[7] 3.3170326 2.315 1.543  0.4558
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  6.7218
## Individual Statistics:              
## mu     0.08225
## mxreg1 0.41994
## omega  0.13694
## alpha1 0.27644
## beta1  0.41037
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          1.28 1.47 1.88
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                    t-value    prob sig
## Sign Bias           0.8882 0.37455    
## Negative Sign Bias  1.7758 0.07596   *
## Positive Sign Bias  0.5215 0.60209    
## Joint Effect        3.5211 0.31804    
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     73.87    2.064e-08
## 2    30     84.92    2.155e-07
## 3    40     91.19    4.590e-06
## 4    50    102.09    1.331e-05
## 
## 
## Elapsed time : 0.2993381

MU OR BETA 0 IS THE MEAN OVER TIME, OMEGA OR ALPHA0 IS THE CONSTANT

IN THE FIRST MODEL

    Estimate  Std. Error  t value

mu -0.000411 0.000427 -0.96124 mxreg1 1.462400 0.048486 30.16134 omega 0.000205 0.000016 12.95602 alpha1 0.164313 0.033264 4.93968 alpha2 0.108845 0.032700 3.32864 alpha3 0.104770 0.037648 2.78290 alpha4 0.044250 0.026640 1.66102 alpha5 0.026766 0.025528 1.04848 Pr(>|t|) mu 0.336431 mxreg1 0.000000 omega 0.000000 alpha1 0.000001 alpha2 0.000873 alpha3 0.005388 alpha4 0.096709 alpha5 0.294420

MU IS NOT SIGNIFICANT AND THE VALUE IS CLOSE TO 0.OMEGA IS CLOSE TO 0 AND MEXREG IS TELLS US THAT FOR EACH UNIT INCREASE IN THE MEXICAN INDEX, CEMEX SHOULD INCREASE IN 1.162400.WE CAN SAY THAT THE SHOCK OF LAG1 AFFECTS IN WAY IN WHIC FOR EACH UNIT IN LAG1, THE VALUE OF TODAY IS AFFECTED IN 0.164313. WE CAN SAY THAT THE SHOCK OF LAG2 AFFECTS IN WAY IN WHICH FOR EACH UNIT IN LAG2, THE VALUE OF TODAY IS AFFECTED IN 0.108845.WE CAN SAY THAT THE SHOCK OF LAG3 AFFECTS IN WAY IN WHIC FOR EACH UNIT IN LAG3, THE VALUE OF TODAY IS AFFECTED IN 0.104770. WE CAN SAY THAT THE SHOCK OF LAG4 AFFECTS IN WAY IN WHIC FOR EACH UNIT IN LAG4, THE VALUE OF TODAY IS AFFECTED IN 0.044250.WE CAN SAY THAT THE SHOCK OF LAG5 AFFECTS IN WAY IN WHIC FOR EACH UNIT IN LAG5, THE VALUE OF TODAY IS AFFECTED IN 0.026766.

IN THE SECOND MODEL

    Estimate  Std. Error   t value

mu -0.000287 0.000416 -0.69028 mxreg1 1.449538 0.049458 29.30841 omega 0.000006 0.000002 3.94861 alpha1 0.051789 0.006121 8.46033 beta1 0.930769 0.007827 118.91390 Pr(>|t|) mu 0.490020 mxreg1 0.000000 omega 0.000079 alpha1 0.000000 beta1 0.000000

MU IS NOT SIGNIFICANT AND THE VALUE IS CLOSE TO 0.OMEGA IS CLOSE TO 0 AND MEXREG IS TELLS US THAT FOR EACH UNIT INCREASE IN THE MEXICAN INDEX, CEMEX SHOULD INCREASE IN 1.449538. FOR ALPHA 1, WE CAN SAY THAT THE SHOCK OF LAG1 AFFECTS IN WAY IN WHIC FOR EACH UNIT IN LAG1, THE VALUE OF TODAY IS AFFECTED IN 0.051789. THE BETA1 REPRESENTS A POSITIVE AND SIGNIFICANT RELATIONSHIP WHEN MU, OMEGA AND ALPHA1 ARE 0