[R] Issues whenWorking with Daily Time Series and Generating Forecasts

Paul Bernal p@u|bern@|07 @end|ng |rom gm@||@com
Tue Jul 14 00:35:51 CEST 2020


Dear friend Erin,

Thank you so much for your kind reply. I have not tried xts nor zoo, but I
will give it a shot and let you know how it goes.

Best regards,

Paul

El lun., 13 jul. 2020 a las 13:44, Erin Hodgess (<erinm.hodgess using gmail.com>)
escribió:

> Hi Paul
>
> Have you looked at the xts or zoo packages, please?
>
> They work very well on daily series.
>
> Thanks,
> Erin
>
> On Mon, Jul 13, 2020 at 12:41 PM Paul Bernal <paulbernal07 using gmail.com>
> wrote:
>
>> Dear friends, hope you are doing great,
>>
>> I am working with a daily time series, the series starts on march,10, 2020
>> until july 9th, 2020.
>>
>> I would like to know if there is a way to make it a ts object, specifying
>> the year, month and day with the ts function.
>>
>> First, I tried setting the ts object as follows:
>>
>> trainingts <- ts(Dataset2$PANCASES, frequency=7)
>>
>> but when I plot trainingts, the x-axis (time axis) shows values like 5,
>> 10,
>> 15 and not the dates.
>>
>> Secondly, I tried doing the following
>>
>> trainingts2 <- ts(Dataset2$PANCASES, start=c(2020,3,10), end=c(2020,7,9),
>> frequency=365.25)
>>
>> but with this setup, now the x-axis has extrange values like 2020.006,
>> 2020.008, etc.
>>
>> Now, when generating forecasts with auto.arima function I get extremely
>> large values for the y-axis, which makes the forecasts look like a flat
>> line:
>>
>> trainingts <- ts(Dataset2$PANCASES, frequency=7)
>>
>> ModelArima2 <- auto.arima(trainingts, lambda=0)
>> ModelArima2For <- forecast(ModelArima2, h=30)
>> plot(ModelArima2For)
>>
>> I am providing the dput() for my dataset below.
>>
>> Any help and/or guidance will be greatly appreciated,
>>
>> Best regards,
>>
>> Paul
>>
>>  > dput(Dataset2)
>> structure(list(DATE = structure(c(18331, 18332, 18333, 18334,
>> 18335, 18336, 18337, 18338, 18339, 18340, 18341, 18342, 18343,
>> 18344, 18345, 18346, 18347, 18348, 18349, 18350, 18351, 18352,
>> 18353, 18354, 18355, 18356, 18357, 18358, 18359, 18360, 18361,
>> 18362, 18363, 18364, 18365, 18366, 18367, 18368, 18369, 18370,
>> 18371, 18372, 18373, 18374, 18375, 18376, 18377, 18378, 18379,
>> 18380, 18381, 18382, 18383, 18384, 18385, 18386, 18387, 18388,
>> 18389, 18390, 18391, 18392, 18393, 18394, 18395, 18396, 18397,
>> 18398, 18399, 18400, 18401, 18402, 18403, 18404, 18405, 18406,
>> 18407, 18408, 18409, 18410, 18411, 18412, 18413, 18414, 18415,
>> 18416, 18417, 18418, 18419, 18420, 18421, 18422, 18423, 18424,
>> 18425, 18426, 18427, 18428, 18429, 18430, 18431, 18432, 18433,
>> 18434, 18435, 18436, 18437, 18438, 18439, 18440, 18441, 18442,
>> 18443, 18444, 18445, 18446, 18447, 18448, 18449, 18450, 18451,
>> 18452), class = "Date"), PANCASES = c(1, 8, 11, 27, 36, 43, 55,
>> 69, 86, 109, 137, 200, 313, 345, 345, 443, 558, 674, 786, 901,
>> 989, 1181, 1181, 1317, 1475, 1673, 1801, 1988, 2100, 2249, 2528,
>> 2752, 2974, 3234, 3400, 3472, 3574, 3751, 4016, 4210, 4273, 4467,
>> 4658, 4821, 5166, 5338, 5538, 5779, 6021, 6021, 6378, 6532, 6720,
>> 7090, 7090, 7197, 7523, 7731, 7868, 8070, 8282, 8448, 8616, 8783,
>> 8944, 9118, 9268, 9449, 9606, 9726, 9867, 9977, 10116, 10267,
>> 10577, 10926, 11183, 11447, 11728, 12131, 12531, 13018, 13463,
>> 13837, 14095, 14609, 15044, 15463, 16004, 16425, 16854, 17233,
>> 17889, 18586, 19211, 20059, 21418, 21422, 21962, 22597, 23351,
>> 24274, 25222, 26030, 26752, 27314, 28030, 29037, 29905, 30658,
>> 31686, 32785, 33550, 34463, 35237, 35995, 36983, 38149, 39334,
>> 40291, 41251, 42216)), row.names = c(NA, -122L), class = "data.frame")
>>
>>         [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
> --
> Erin Hodgess, PhD
> mailto: erinm.hodgess using gmail.com
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list