R Tutorial: Basic time series objects

preview_player
Показать описание

---
A time series is more than a vector of numbers, it also includes the time indices for each observation.

Given a vector of numbers you can apply the ts() function to create a time series object. Such objects are of the `ts` class. They represent data that is at least approximately evenly spaced over time.

Consider the following data_vector which has just eight observations.

To make this vector a time series object you apply the ts() function

When you plot the result using the plot() function the time index and label is automatically added to the horizontal axis. By default, R uses a simple observation index starting from 1 as the time index.

If you want the time series to start in the year 2001 with 1 observation per year you should apply the ts() function with the additional arguments start = 2001 and frequency = 1 as shown. Now when you plot the result you can see an updated time axis, running from 2001 through 2008.

Remember: why do you want to create and work with time series objects of the ts class?
There are many methods and functions available for utilizing time series attributes, especially for plotting and for accessing time index information. And as we will see in later chapters, for estimating time series models and for making forecasts.

Now let's practice with some exercises!

#DataCamp #RTutorial #TimeSeries #Analysis
Рекомендации по теме
Комментарии
Автор

Any book about time series in ML on R?

ilyasikm
Автор

How can I insert the date into a TS object, ie in this format "% d /% m /% Y"?

alessandrorosati