Characteristics of financial time series
Daily financial asset returns typically share many characteristics. Returns over one day are typically small, and their average is close to zero. At the same time, their variances and standard deviations can be relatively large. Over the course of a few years, several very large returns (in magnitude) are typically observed. These relative outliers happen on only a handful of days, but they account for the most substantial movements in asset prices. Because of these extreme returns, the distribution of daily asset returns is not normal, but heavy-tailed, and sometimes skewed. In general, individual stock returns typically have even greater variability and more extreme observations than index returns.
In this exercise, you'll work with the eu_percentreturns
dataset, which is the percentage returns calculated from your eu_stocks
data. For each of the four indices contained in your data, you'll calculate the sample mean, variance, and standard deviation.
Notice that the average daily return is about 0, while the standard deviation is about 1 percentage point. Also apply the hist()
and qqnorm()
functions to make histograms and normal quantile plots, respectively, for each of the indices.
This exercise is part of the course
Time Series Analysis in R
Exercise instructions
- Use
colMeans()
to calculate the sample mean for each column in youreu_percentreturns
data. - Use
apply()
to calculate the sample variance for each index. Leave theMARGIN
argument at2
and set theFUN
argument tovar
. - Use another call to
apply()
to calculate the standard deviation for each index. Keep theMARGIN
argument at2
but this time set theFUN
argument tosd
. - Run the remaining code to display a histogram and normal quantile plots of percent returns for each index.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Generate means from eu_percentreturns
colMeans(___)
# Use apply to calculate sample variance from eu_percentreturns
apply(___, MARGIN = 2, FUN = ___)
# Use apply to calculate standard deviation from eu_percentreturns
# Display histogram and normal quantile plots
par(mfrow = c(2,2))
apply(eu_percentreturns, MARGIN = 2, FUN = hist, main = "", xlab = "Percentage Return")
par(mfrow = c(2,2))
apply(eu_percentreturns, MARGIN = 2, FUN = qqnorm, main = "")
qqline(eu_percentreturns)