Problem1. Write a brief description of the time series plots of the four indices. Do the series look stationary? Do the fluctuations in the series seem to be of constant size? If not, describe how the volatility fluctuates.
rm(list=ls())
data(EuStockMarkets)
mode(EuStockMarkets)
## [1] "numeric"
class(EuStockMarkets)
## [1] "mts" "ts" "matrix"
plot(EuStockMarkets)

logR = diff(log(EuStockMarkets))
plot(logR)

# Yes. The series look stationary.
Problem2. Write a brief description of the time series plots of the four series of log returns. Do the series look stationary? Do the fluctuations in the series seem to be of constant size? If not, describe how the volatility fluctuates.
plot(as.data.frame(logR))

par(mfrow=c(2, 2))
for(i in colnames(logR))
{
qqnorm(logR[ ,i], datax = T, main = i)
qqline(logR[ ,i], datax = T)
print(shapiro.test(logR[ ,i]))
}
##
## Shapiro-Wilk normality test
##
## data: logR[, i]
## W = 0.95384, p-value < 2.2e-16
##
## Shapiro-Wilk normality test
##
## data: logR[, i]
## W = 0.95537, p-value < 2.2e-16
##
## Shapiro-Wilk normality test
##
## data: logR[, i]
## W = 0.98203, p-value = 1.574e-14

##
## Shapiro-Wilk normality test
##
## data: logR[, i]
## W = 0.97994, p-value = 1.754e-15
# The plots of the four series look heavier than the normal. As I observed with the Shapiro-Wilk tests in four series is less than 1 and the p-value is less than 0.05. So the null hyphotesis is not supported with 95%.
Problem 3. Briefly describe the shape of each of the four normal plots and state whether the marginal distribution of each series is skewed or symmetric and whether its tails appear normal. If the tails do not appear normal, do they appear heavier or lighter than normal? What conclusions can be made from the Shapiro–Wilk tests? Include the plots with your work.
n=dim(logR)[1]
q_grid = (1:n) / (n + 1)
df_grid = c(1, 4, 6, 10, 20, 30)
index.names = dimnames(logR)[[2]]
for(i in 1:4)
{
#dev.new()
par(mfrow = c(3, 2))
for(df in df_grid)
{
qqplot(logR[,i], qt(q_grid,df),
main = paste(index.names[i], ", df = ", df) )
abline(lm(qt(c(0.25, 0.75), df = df) ~
quantile(logR[,i], c(0.25, 0.75))))
}
}




# When degree of freedom is equal to 6, each of the plot will be normal distribution. If the plots will be heavier or ligher than normal, the tails will not appear normal.