MulaiMulai sekarang secara gratis

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.

Latihan ini adalah bagian dari kursus

Visualizing Time Series Data in R

Lihat Kursus

Petunjuk latihan

  • Plot data and name the chart "Apple stock price"
  • Apply ROC() to data to create a time series rtn containing Apple's daily returns
  • Plot data and rtn, in that order, as two new plots on a 1x2 graphical window

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Plot Apple's stock price 


# Create a time series called rtn


# Plot Apple daily price and daily returns 


Edit dan Jalankan Kode