Time Series Analysis with R programming
Here is a tutorial on how to use R programming software to carry out time series analysis
To load data set from the package “fma”, use the commands:
{` >data (package=fma) This instantly loads the pre existing data sets in the package. To load the data set regarding sales of one family houses, use the command: >data (hsales) To print the data: >hsales`}
How to create a time series data in R programming?
Now, form a time series from the data using the command:
{`>timeseries <- ts (hsales, frequency=12, start=1973) Here, the variable name is “timeseries”, feequency is 12(because it is monthly data), and start=1 (since the data starts from 1973) Now, print the series: >timeseries `}
How to plot the time series graph in R program?
{`To plot the time series, use the command: >plot.ts (timeseries, main=”Sales of one family houses”)`}
Decomposing an additive and multiplicative Time Series model in R
{`To decompose the time series into its components, use the command in R statistical software: >timeseriescomponents <- decompose (timeseries) Print the decomposed series, >timeseriescomponents`}
{`You can also plot the decomposed time series components using R software >plot (timeseriescomponents) `}