Aggregating log-return series
In statistics, aggregate data are data combined from several measurements. You just learned that you can compute compute weekly, monthly and quarterly log-returns by summing daily log-returns with the corresponding apply.weekly(), apply.monthly() and apply.quarterly() functions.
For example, you can use the following code to form the quarterly returns for a univariate time series data and multivariate time series mv_data:
> # apply.quarterly(x, FUN, ...)
> data_q = apply.quarterly(data, sum)
> mv_data_q = apply.quarterly(mv_data, colSums)
In this exercise, you will practice aggregating time series data using these functions and plotting the results. The data DJ and DJ_const are available in your workspace, as are the objects djx, which contains daily log-returns of the Dow Jones index from 2000-2015, and djreturns, which contains the daily log-returns for the first four DJ_const stocks from 2000-2015. Use plot for univariate time series and plot.zoo for multivariate time series.
Diese Übung ist Teil des Kurses
Quantitative Risk Management in R
Anleitung zur Übung
- Plot the object
djx. - In one line, plot the weekly log-returns of
djxwith vertical bars. - Plot the monthly log-returns of
djxwith vertical bars. - Plot the object
djreturnsusingplot.zoo. - Plot the monthly log-returns for
djreturnswith vertical bars usingplot.zoo.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# Plot djx
___(___)
# Plot weekly log-returns of djx
___(___, ___)
# Plot monthly log-returns of djx
___(___, ___)
# Plot djreturns
___(___)
# Plot monthly log-returns of djreturns
___(___, ___)