Representing a univariate time series
The very first step in the analysis of any time series is to address if the time series have the right mathematical properties to apply the standard statistical framework. If not, you must transform the time series first.
In finance, price series are often transformed to differenced data, making it a return series. In R, the ROC()
(which stands for "Rate of Change") function from the TTR
package does this automatically to a price or volume series x
:
ROC(x)
In this exercise, you will compare plots of the Apple daily prices and Apple daily returns using the stock data contained in data
, which is available in your workspace.
Este ejercicio forma parte del curso
Visualizing Time Series Data in R
Instrucciones del ejercicio
- Plot
data
and name the chart "Apple stock price" - Apply
ROC()
todata
to create a time seriesrtn
containing Apple's daily returns - Plot
data
andrtn
, in that order, as two new plots on a 1x2 graphical window
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
# Plot Apple's stock price
# Create a time series called rtn
# Plot Apple daily price and daily returns