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`}
![Time Series Analysis with R programming Time Series Analysis with R programming](https://www.assignmenthelp.net/webimg/yah/images/time-series-analysis-using-r-program.png)
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 `}
![time series data in R programming time series data in R programming](https://www.assignmenthelp.net/webimg/yah/images/time-series-data-in-r-programming.png)
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”)`}
![Time series Analysis using R program Time series Analysis using R program](https://www.assignmenthelp.net/webimg/yah/images/plot-the-time-series-graph-in-r-program.png)
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`}
![Time series Analysis using R program image 1 Time series Analysis using R program image 1](https://www.assignmenthelp.net/webimg/yah/images/time-series-analysis-using-r-program-image-1.png)
![Time series Analysis using R program image 2 Time series Analysis using R program image 2](https://www.assignmenthelp.net/webimg/yah/images/time-series-analysis-using-r-program-image-2.png)
![Time series Analysis using R program image 3 Time series Analysis using R program image 3](https://www.assignmenthelp.net/webimg/yah/images/time-series-analysis-using-r-program-image-3.png)
{`You can also plot the decomposed time series components using R software >plot (timeseriescomponents) `}
![Time series Analysis using R program image 4 Time series Analysis using R program image 4](https://www.assignmenthelp.net/webimg/yah/images/time-series-analysis-using-r-program-image-4.png)