Decomposition of the time series is to split a time series into different constituent components. The general sequence (non-seasonal sequence) consists of a trend part and an irregular part (that is, a random part), and if it is a seasonal sequence, there are also seasonal parts in addition to the two above.
Here, let's start with--the decomposition of non-seasonal data.
a non-seasonal time series consists of a trend part and an irregular part. The Decomposition time series is an attempt to split the time series into these points, that is, to estimate the two parts of the trend and irregularities.
In order to estimate the trend part of a non-seasonal time series, so that it can be described by the additive model, the most common method is smoothing method, such as calculating the simple moving average of time series. At this point, we need to use the SMA () function in the "TTR" package.
when using the SMA () function, you need to simply move the flat by specifying the parameter "n" the span of all. For example, for a simple, easy-to-understand average with a span of 5, we set n=5 in the SMA () function.
As mentioned above, the age data for the death of the 42 British Kings is non-seasonal and due to their random changes throughout the time period is large immutable, this sequence can also be described as an additive model.
> King<-scan ("Http://robjhyndman.com/tsdldata/misc/kings.dat", skip=3)
Read the items
> King
[1] 60 43 67 50 56 42 50 65 68 43 65 34 47 34 49 41 13 35 53 56 16 43 69 59
[25] 48 59 86 55 68 51 33 49 67 77 81 67 71 81 68 70 77 56
> Kingts<-ts (King)
Use the SMA () function of the TTS package for a simple moving average.
>kingstime<-sma (kingts,n=8)
>plot.ts (Kingstime)
The trend portion of the simple moving average smoothing data for this span of 8 looks clearer, and we can find the time series before 20 for the king to go age from the first 55 years to 38 years, and then up to the 40th session of the King's 73 years of age.
R Learning Diary-decomposition Time series (non-seasonal data)