Dear R users, I am fronting my firts time series problem. I have hourly temperature data for 3 years (from 01/01/2013 to 5/02/2016). I would like to use those in order to PREDICT TEMPERATURE OF THE NEXT HOURS according to the observations. A subset of the data look like this: date <- rep(seq(as.Date("14-01-01"), as.Date("14-01-03"), by="days"), 24) hour <-rep(c(paste0("0",0:9,":00:00"), paste0(10:23,":00:00")),3) temperature <- c(6.1, 6.8, 6.5, 7.2, 7.1, 7.9, 5.9, 6.8, 7.7, 9.5, 12.6, ???????????????? 14.0, 15.9, 17.3, 17.5, 17.2, 15.0, 14.1, 13.1, 11.7, 10.9, ???????????????? 11.0, 11.6, 11.0, 11.2, 11.0, 11.0, 11.4, 12.2, 13.7, 12.9, ???????????????? 12.9, 12.8, 13.4, 13.9, 14.9, 16.6, 16.0, 15.2, 15.4, 14.7, ???????????????? 14.6, 13.3, 13.0, 13.8, 13.1, 12.0, 11.9, 11.8, 11.6, 11.0, ???????????????? 11.2, 11.6, 10.6, 9.5, 9.8, 9.9, 11.7, 15.3, 18.6, 20.7, ???????????????? 22.2, 22.2, 20.8, 20.2, 18.3, 15.6, 13.6, 12.8, 13.1, 13.7, 14.7) dfExample <- data.frame(date, hour, temperature)? So as to plot 3 years ( from 01/01/2013 to 31/12/2015) I use this code and obtained the attached picture. It is observed seasonality. tempdf4 <- ts(df4$temperature, frequency=365*24*3) plot.ts(tempdf4) Am I doing it well? Could you help me with any information in this type of problem (mainly with the prediction). For example, if I want to use Arima, according with my data structure, what are the arguments of the funcion?? fit=Arima(df4$temperature, seasonal=list(order=c(xxx,xxx,xxx),period=xxx) plot(forecast(fit)) I could use also some predictions from other source that I am collecting since January, 2016. But I would prefer to understand the simplest way to solve the problem and then, progressively, understand more complex approaches. Thank you very much for any kind of help. ------ Aurora Gonz?lez Vidal Phd student in Data Analytics for Energy Efficiency Faculty of Computer Sciences University of Murcia @. aurora.gonzalez2 at um.es T. 868 88 7866 www.um.es/ae ------------ pr?xima parte ------------ A non-text attachment was scrubbed... Name: Rplot.png Type: image/png Size: 9610 bytes Desc: no disponible URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20160205/45a2d22b/attachment.png>
Try the auto.arima function in the forecast package.. Regards, DR SEAN PORTER Scientist South African Association for Marine Biological Research Direct Tel: +27 (31) 328 8169 Fax: +27 (31) 328 8188 E-mail: sporter at ori.org.za Web: www.saambr.org.za 1 King Shaka Avenue, Point, Durban 4001 KwaZulu-Natal South Africa PO Box 10712, Marine Parade 4056 KwaZulu-Natal South Africa -----Original Message----- From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of AURORA GONZALEZ VIDAL Sent: 05 February 2016 10:50 AM To: r-help at r-project.org Subject: [R] hourly prediction time series Dear R users, I am fronting my firts time series problem. I have hourly temperature data for 3 years (from 01/01/2013 to 5/02/2016). I would like to use those in order to PREDICT TEMPERATURE OF THE NEXT HOURS according to the observations. A subset of the data look like this: date <- rep(seq(as.Date("14-01-01"), as.Date("14-01-03"), by="days"), 24) hour <-rep(c(paste0("0",0:9,":00:00"), paste0(10:23,":00:00")),3) temperature <- c(6.1, 6.8, 6.5, 7.2, 7.1, 7.9, 5.9, 6.8, 7.7, 9.5, 12.6, 14.0, 15.9, 17.3, 17.5, 17.2, 15.0, 14.1, 13.1, 11.7, 10.9, 11.0, 11.6, 11.0, 11.2, 11.0, 11.0, 11.4, 12.2, 13.7, 12.9, 12.9, 12.8, 13.4, 13.9, 14.9, 16.6, 16.0, 15.2, 15.4, 14.7, 14.6, 13.3, 13.0, 13.8, 13.1, 12.0, 11.9, 11.8, 11.6, 11.0, 11.2, 11.6, 10.6, 9.5, 9.8, 9.9, 11.7, 15.3, 18.6, 20.7, 22.2, 22.2, 20.8, 20.2, 18.3, 15.6, 13.6, 12.8, 13.1, 13.7, 14.7) dfExample <- data.frame(date, hour, temperature) So as to plot 3 years ( from 01/01/2013 to 31/12/2015) I use this code and obtained the attached picture. It is observed seasonality. tempdf4 <- ts(df4$temperature, frequency=365*24*3) plot.ts(tempdf4) Am I doing it well? Could you help me with any information in this type of problem (mainly with the prediction). For example, if I want to use Arima, according with my data structure, what are the arguments of the funcion?? fit=Arima(df4$temperature, seasonal=list(order=c(xxx,xxx,xxx),period=xxx) plot(forecast(fit)) I could use also some predictions from other source that I am collecting since January, 2016. But I would prefer to understand the simplest way to solve the problem and then, progressively, understand more complex approaches. Thank you very much for any kind of help. ------ Aurora Gonz?lez Vidal Phd student in Data Analytics for Energy Efficiency Faculty of Computer Sciences University of Murcia @. aurora.gonzalez2 at um.es T. 868 88 7866 www.um.es/ae
AURORA GONZALEZ VIDAL
2016-Feb-07 13:36 UTC
[R] evaluation + Re: hourly prediction time series
Thank you, it works fine. Now, I am trying to evaluate the performance of the model across time. So as to do that I use rolling window which I understand as sort of a "leave one out". The example: The data are from the 1st of January to nowadays so, I use data from the 1st of January to the 1st of December to fit the model and then I predict the temperatures of the 2nd of December. As I have the real ones, I can compute RMSE or other metrics. Then, I use data from 1st of January to the 2nd of December in order to predict the 24 values of temperature on the 3rd of December, and later I compute again the RMSE (between predicted and real of the 3rd). So on untill I have no more data. Then, I have several RMSE, I compute their mean and sd and I consider this as the evaluation of the model's performance. The question is: do you know any book or documentation where I can cosult how many times should I do this process so as to know where I should start. Should I start before December to do the rolling? I mean, is there any agreement? For example, if I have 400 days of data, meaning 9600 (400 * 24) observations maybe I could choose a 10 % of the windows so as to start evaluating, which means, do the process 40 times starting with the day 360. Any source of information will be appreciated. Sean Porter <sporter at ori.org.za> escribi?:> Try the auto.arima function in the forecast package.. > > Regards, > > DR SEAN PORTER > Scientist > > South African Association for Marine Biological Research > Direct Tel: +27 (31) 328 8169? ?Fax: +27 (31) 328 8188 > E-mail: sporter at ori.org.za Web: www.saambr.org.za[1] > 1 King Shaka Avenue, Point, Durban 4001 KwaZulu-Natal South Africa > PO Box 10712, Marine Parade 4056 KwaZulu-Natal South Africa > > -----Original Message----- > From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of AURORA > GONZALEZ VIDAL > Sent: 05 February 2016 10:50 AM > To: r-help at r-project.org > Subject: [R] hourly prediction time series > > Dear R users, > > I am fronting my firts time series problem. I have hourly temperature > data for 3 years (from 01/01/2013 to 5/02/2016). I would like to use > those in order to PREDICT TEMPERATURE OF THE NEXT HOURS according to the > observations. > > A subset of the data look like this: > > date <- rep(seq(as.Date("14-01-01"), as.Date("14-01-03"), by="days"), > 24) hour <-rep(c(paste0("0",0:9,":00:00"), paste0(10:23,":00:00")),3) > temperature <- c(6.1, 6.8, 6.5, 7.2, 7.1, 7.9, 5.9, 6.8, 7.7, 9.5, 12.6, > ? ? ? ? ? ? ? ? 14.0, 15.9, 17.3, 17.5, 17.2, 15.0, 14.1, 13.1,11.7,> 10.9, > ? ? ? ? ? ? ? ? 11.0, 11.6, 11.0, 11.2, 11.0, 11.0, 11.4, 12.2,13.7,> 12.9, > ? ? ? ? ? ? ? ? 12.9, 12.8, 13.4, 13.9, 14.9, 16.6, 16.0, 15.2,15.4,> 14.7, > ? ? ? ? ? ? ? ? 14.6, 13.3, 13.0, 13.8, 13.1, 12.0, 11.9, 11.8,11.6,> 11.0, > ? ? ? ? ? ? ? ? 11.2, 11.6, 10.6, 9.5, 9.8, 9.9, 11.7, 15.3,18.6, 20.7,> ? ? ? ? ? ? ? ? 22.2, 22.2, 20.8, 20.2, 18.3, 15.6, 13.6, 12.8,13.1,> 13.7, 14.7) > > dfExample <- data.frame(date, hour, temperature) > > So as to plot 3 years ( from 01/01/2013 to 31/12/2015) I use this code > and obtained the attached picture. It is observed seasonality. > > tempdf4 <- ts(df4$temperature, frequency=365*24*3) > plot.ts(tempdf4) > > Am I doing it well? Could you help me with any information in this type > of problem (mainly with the prediction). For example, if I want to use > Arima, according with my data structure, what are the arguments of the > funcion?? > > fit=Arima(df4$temperature, seasonal=list(order=c(xxx,xxx,xxx),period=xxx) > plot(forecast(fit)) > > I could use also some predictions from other source that I am collecting > since January, 2016. But I would prefer to understand the simplest way > to solve the problem and then, progressively, understand more complex > approaches. > > Thank you very much for any kind of help. > > ------ > Aurora Gonz?lez Vidal > Phd student in Data Analytics for Energy Efficiency > > Faculty of Computer Sciences > University of Murcia > > @. aurora.gonzalez2 at um.es > T. 868 88 7866www.um.es/ae[2]V?nculos: --------- [1] http://www.saambr.org.za [2] http://7866www.um.es/ae ------ Aurora Gonz?lez Vidal Phd student in Data Analytics for Energy Efficiency Faculty of Computer Sciences University of Murcia @. aurora.gonzalez2 at um.es T. 868 88 7866 www.um.es/ae [[alternative HTML version deleted]]