Basic time series objects

Time Series Analysis in R

David S. Matteson

Associate Professor at Cornell University

Building ts() objects - I

  • Start with a vector of data
  • Apply the ts() function
data_vector
10 6 11 8 10 3 6 9
time_series <- ts(data_vector)
plot(time_series)

Time Series Analysis in R

Building ts() objects - II

  • Specify the start date and observation frequency:
    time_series <- ts(data_vector, start = 2001, frequency = 1)
    
plot(time_series)

Time Series Analysis in R

Using is.ts()

  • The is.ts() function checks whether an object is of the ts()class:
is.ts(data_vector)
FALSE
is.ts(time_series)
TRUE
Time Series Analysis in R

Why ts() objects?

Why create and use time series objects of the ts() class?

  • Improved plotting.
  • Access to time index information.
  • Model estimation and forecasting (later chapters).
Time Series Analysis in R

Let's practice!

Time Series Analysis in R

Preparing Video For Download...