Mark K
Mark K

Reputation: 9348

R, incomplete elements in time series decomposition

I am using below codes to perform time series decomposition.

a <- c( 4, 3, 2, 12, 6, 6, 13, 9, 9, 11, 8, 6, 15, 3, 3, 4, 4, 12, 14, 11, 3, 10, 5, 5)

ts_a = ts(a, frequency = 12)

decompose_a = decompose(ts_a, 'additive')
plot(decompose_a)

decompose_a = decompose(ts_a, 'multiplicative')
plot(decompose_a)

The plot shows the trend decomposed is incomplete. How should I interpret this?

Is it no complete trend can be extracted from this time series? (likewise the randomness)

Thank you.

enter image description here

enter image description here

Upvotes: 3

Views: 308

Answers (1)

Philopolis
Philopolis

Reputation: 555

With the arguments you provide, decompose() function uses a moving average to compute the trend component (see help(decompose), and help(filter) for technical details about the computations). The moving window has a length of 12 months in both backward and forward directions, i.e. is centered on a given month and utilize the values 6 months before and 6 months after.

Consequently, by definition, you cannot have trend values for the first six and last six months of your data, since the moving average cannot be computed for those months.

Upvotes: 3

Related Questions