How to do it...

Perform the following steps in R:

> plot(my_series) 
Plot of m y_series
> plot(AirPassengers) 
Plot of AirPassengers
> cycle(AirPassengers) 
Output: 
     Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec 
1949   1   2   3   4   5   6   7   8   9  10  11  12 
1950   1   2   3   4   5   6   7   8   9  10  11  12 
1951   1   2   3   4   5   6   7   8   9  10  11  12 
1952   1   2   3   4   5   6   7   8   9  10  11  12 
1953   1   2   3   4   5   6   7   8   9  10  11  12 
1954   1   2   3   4   5   6   7   8   9  10  11  12 
1955   1   2   3   4   5   6   7   8   9  10  11  12 
1956   1   2   3   4   5   6   7   8   9  10  11  12 
1957   1   2   3   4   5   6   7   8   9  10  11  12 
1958   1   2   3   4   5   6   7   8   9  10  11  12 
1959   1   2   3   4   5   6   7   8   9  10  11  12 
1960   1   2   3   4   5   6   7   8   9  10  11  12 
> aggregate(AirPassengers) 
Output: 
Time Series: 
Start = 1949  
End = 1960  
Frequency = 1  
 [1] 1520 1676 2042 2364 2700 2867 3408 3939 4421 4572 5140 5714 
 
> plot(aggregate(AirPassengers)) 
Plot of AirPassengers using aggregate
> boxplot(AirPassengers~cycle(AirPassengers)) 
Box plot to see month wise pattern
> install.packages("forecast") 
> require(forecast) 
> forecast(my_series, 4) 
Output: 
         Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95 
Jan 2017       3306.796 2722.674 3890.918 2413.459 4200.133 
Feb 2017       3306.796 2722.674 3890.918 2413.459 4200.133 
Mar 2017       3306.796 2722.674 3890.918 2413.459 4200.133 
Apr 2017       3306.796 2722.674 3890.918 2413.459 4200.133 
 
> f = HoltWinters(my_series) 
> forecast(f,4) 
Output: 
         Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95 
Jan 2017       3597.549 2944.407 4250.691 2598.655 4596.444 
Feb 2017       3701.691 3048.549 4354.833 2702.797 4700.585 
Mar 2017       3172.856 2519.714 3825.997 2173.961 4171.750 
Apr 2017       3106.034 2452.892 3759.176 2107.140 4104.928 
 
> forecast(AirPassengers, 4) 
Output: 
         Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95 
Jan 1961       441.7479 420.9284 462.5675 409.9071 473.5887 
Feb 1961       433.0931 407.5924 458.5938 394.0931 472.0931 
Mar 1961       496.6067 462.3205 530.8930 444.1705 549.0430 
Apr 1961       483.5263 445.6985 521.3541 425.6737 541.3790 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset