I have a dataset from 27-Oct-2015 to 24-Feb-2016, with time interval of 1 minute. Data zz
as below:
Details of zz
data can be found in this link: https://drive.google.com/file/d/1IzoIpyiedh_33UJ5SbdrwJTj6cEGSqtZ/view?usp=sharing
,dataid,meter_value
2015-10-27 19:50:00,1103,183138
2015-10-27 19:51:00,1103,183138
2015-10-27 19:52:00,1103,183138
:
2016-02-24 00:38:00,1103,197015.985697259
2016-02-24 00:39:00,1103,197015.992848629
2016-02-24 00:40:00,1103,197016
I created timeseries from 2015-10-27 19:50:00 to 2015-12-31 23:59:00 with frequency interval=10080, to forecast the meter_value from 2016-01-01 00:00:00 to 2016-02-24 00:40:00, and compare with my real data. My timeseries of R code as below:
I tried using different frequency value such as 60, 1440, 525960, but I still get same result as frequency value=10080
mytsTT <- ts(zz$meter_value, start = c(2015,10,27,19,50), end = c(2015,12,31,23,59), frequency = 10080)
str(mytsTT)
#Time-Series [1:3] from 2015 to 2015: 183138 183138 183138
# - attr(*, "index")= POSIXct[1:3], format: "2015-10-27 19:50:00" ...
# - attr(*, "frequency")= num 0.0167
I updated mytsTT
according to nwerth's code, but my forecasting points are weird.
I was trying to forecasting meter_value from "2016-01-01 00:00:00 to 2016-02-24 00:40:00" and compare with real data but my forecasting points are not correct.
When i convert two forecasting points, I got this output which is not correct. I expected to get forecasting points "2016-01-01 00:00:00 to 2016-02-24 00:40:00" but what i got for forecasting points are from 93851 to 94850
> as.POSIXct.Date(94850)
[1] "2229-09-10 08:00:00 +08"
> as.POSIXct.Date(93851)
[1] "2226-12-16 08:00:00 +08"
start_time <- as.POSIXct("2015-10-27 19:50")
end_time <- as.POSIXct("2015-12-31 23:59")
mytsTT2 <- ts(zoo(
zz$meter_value,
order.by = seq.POSIXt(start_time, end_time, by = "mins"),
frequency = 10080
))
str(mytsTT2)
# Time-Series [1:93850] from 1 to 93850: 183138 183138 183138 183138 183138 ...
# - attr(*, "index")= POSIXct[1:93850], format: "2015-10-27 19:50:00" ...
# - attr(*, "frequency")= num 10080
Forecasting R-code:
autoplot(forecast(mytsTT2,1000))
write.csv(forecast(mytsTT2,1000),"D1103-mytsTT2-1000fc.csv",quote=F)
Original data and forecasting data