Question: Using the attached R code (le1.R) get the daily equity prices data for the Japanese Nikkei 225 stock index for the period 2005/01/04-2021/12/31 from finance.yahoo.com

Using the attached R code (le1.R) get the daily equity prices data for the Japanese Nikkei 225 stock index for the period 2005/01/04-2021/12/31 from finance.yahoo.com (use ticker ^N225) and answer questions 1-3.

Note that you need to make several changes in the code, such as replacing ^GSPC index with ^N225 and several other parameters in the code.

1. Compute the log returns for Nikkei and find the statistics below.

a) Find the mean annualized return.

b) Find the annualized volatility (standard deviation for the whole sample).

c) Find the skewness and kurtosis and explain if there is any asymmetry and fat tails?

d) Formulate and test the efficient market hypothesis (EMH) using the Q test for returns for k=15 autocorrelations.

e) Formulate and test the null hypothesis of no volatility clustering using the Q test for squared returns for k=15 autocorrelations.

2. Using the same data find annualized Monthly and Annual historical volatilities for the whole period. Here use moving average standard deviations with monthly (22 days) window and annual (252 days) window. In both cases annualize the volatilities using sqrt(252) multiplier since we use daily data. Present a plot of both volatilities on one graph. Do you observe that volatilities are changing over time? What are the main events that caused volatility peaks for Nikkei index?

3. Find exponentially weighted volatilities (EWMA) using .94 and .98 as the smoothing parameter. Plot both of these series on the same graph and attach it. Which parameter gives smoother volatility graph? Code:

# R code ############################################################################## ############################################################################## rm(list = ls()) # clear memory par(mfrow=c(1,1)) # one window for graphics ############################################################################## ##Below make changes to the code and answer questions in LE1 library(quantmod) # <=== load the package "quantmod" getSymbols("^GSPC", from="2005-01-03",to="2021-12-31") # <=== get daily SP500 stock data from Yahoo Finance Price=GSPC$GSPC.Adjusted # <==Column 6 of the object "GSPC" in R ret=100*diff(log(Price)) plot(Price) plot(ret) ##<==notice that there is NA 1st observation in returns. Let's remove it ret=na.omit(ret) length(ret) #<===now we have 4278 observations for returns after dropping NA obs library(xts) dates=index(ret)#<===extract dates from xts object ret0=coredata(ret)#<==remove time series property from returns library(fBasics) #<== Load the package "fBasics" basicStats(ret) #<== Compute descriptive statistics of log returns. NOTE that Excess Kurtosis is reported. #<==(Kurtosis-3) mean(ret) #mean var(ret) #variance stdev(ret) # standard deviation sd(ret) #standard deviation skewness(ret) #skewness kurtosis(ret) #<==(Kurtosis-3) normalTest(ret,method='jb') # #<== Perform normality test.JB-test #Correlogram q = acf(ret0,20) #<== Compute and plot autocorrelation for 20 lags starting from lag 0. plot(q[1:20]) #<== plot autocorrelation for 20 lags starting from lag 1. b = Box.test(ret0,lag=20,type="Ljung-Box") #<==Q test b q2 = acf(ret0^2,20) #<== Compute and plot autocorrelation of squared returns for 20 lags starting from lag 0. plot(q2[1:20]) #<== plot autocorrelation for 20 lags starting from lag 1. b2 = Box.test(ret0^2,lag=20,type="Ljung-Box") #<==Q test b2 # Monthly Historical Standard Deviation (Rolling function) vol=rollapply(ret,22,sd) # moving average of 22 observations standard deviations vol_22=sqrt(252)*vol #Annualized volatility plot(vol_22,main ="Historical Monthly Volatility", ylab="Standard Deviation, annualized", col="red") # Annualized Historical Standard Deviation (Rolling function) vol=rollapply(ret,252,sd) # moving average of 252 observations standard deviations vol_252=sqrt(252)*vol #Annualized volatility plot(vol_252,main ="Historical Annual Volatility", ylab="Standard Deviation, annualized", col="red") ##Plot two graphs on one plot vol=cbind(vol_22,vol_252) # combine two time series in a matrix plot(vol, col=c(1,2)) title("Volatility plots: Historical Rolling Standard Deviations") legend("right", inset=0.03, legend=c("monthly", "annual"),pch=1, col=c(1,2), horiz=F) # EWMA Riskmetrics model library("MTS") m1=EWMAvol(ret, lambda = 0.99) # this is RISKMETRICS model with smoothing .99 sig2_ewma=m1$Sigma.t #estimated daily variance from object m1 # Annualized EWMA volatility s_smooth=sqrt(252*sig2_ewma) library(xts) vol_s99=as.xts(s_smooth, dates) plot(vol_s99) title("Riskmetrics Volatility with lambda=.99") m2=EWMAvol(ret, lambda = 0.94) #<--smoothing with lambda .94 # Annualized EWMA volatility s_smooth=sqrt(252*m2$Sigma.t) vol_s94=as.xts(s_smooth, dates) plot(vol_s94) title("Riskmetrics Volatility with lambda=.94") vol_smooth=cbind(vol_s94,vol_s99) # combine two time series in a matrix plot(vol_smooth, col=c(1,2)) title("Volatility plots: EWMA") legend("right", inset=0.03, legend=c("vol_s94","vol_s99"),pch=1, col=c(1,2), horiz=F) 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Finance Questions!