Remove leading zeros from time series in R -
I have a time series with the following method and I am wondering if a smart move to remove a leading driver Can show. The reason why I want to save is that this prediction can have a negative impact on the selection of the model.
Example Series Series:
Time-series & lt; - ts (c (0 (0, 0, 0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 10, 10, 16, 7, 13, 0, 9, 1, 11, 2, 11, 3, 11, 4, 1, 20, 13, 18, 19, 16, 16, 16, 15 , 14, 27, 24, 35, 8, 18, 21, 20, 19, 22, 18, 21), start = c (2001,6), frequency = 12) I can visualize a process of doing several tests with the time series subsets and then reducing the leading series of zero with subsets with only zero, however, it would be a cumbersome process, in terms of calculation There is a possibility of being disabled.
Is anyone already aware of doing this efficiently with any existing work or process?
Only the principal zeroes and leaves are removed in this other void:
From time to time [cumsum]! = 0] # [1] 9 10 10 16 7 13 9 1 11 2 11 3 11 4 1 20 13 18 19 16 16 15 14 27 24 35 8 18 21 20 1 9 18 18 21 Why is this trick? cumsum has been added: cumsum (time-series) [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 9 29 45 52 65 65 74 75 [33] 86 88 99 102 113 117 118 138 151 16 9 188 204 220 236 251 265 292 316 351 35 9 377 398 418 418 437 45 9 477 498 Thus, in only those cases where there are zero results, is equal to zero. If the time zero becomes zero on the basis of zero then there will be no change in the quem, but Will not be zero.
If you can use repeatedly, there are negative values:
time-series [cumsum (abs (timeshariers)) = 0]
Comments
Post a Comment