| 1 | -----r |
| 2 | library(talweg) |
| 3 | |
| 4 | P = ${P} #première heure de prévision |
| 5 | H = ${H} #dernière heure de prévision |
| 6 | |
| 7 | ts_data = read.csv(system.file("extdata","pm10_mesures_H_loc.csv", |
| 8 | package="talweg")) |
| 9 | exo_data = read.csv(system.file("extdata","meteo_extra_noNAs.csv", |
| 10 | package="talweg")) |
| 11 | data = getData(ts_data, exo_data) |
| 12 | |
| 13 | indices = seq(as.Date("2015-01-01"),as.Date("2015-12-31"),"days") |
| 14 | -----r |
| 15 | p1 = computeForecast(data, indices, "Neighbors", "Neighbors", |
| 16 | predict_from=P, horizon=H, simtype="mix", local=FALSE) |
| 17 | p2 = computeForecast(data, indices, "Neighbors", "Zero", |
| 18 | predict_from=P, horizon=H, simtype="none", local=TRUE) |
| 19 | p3 = computeForecast(data, indices, "Average", "LastValue", |
| 20 | predict_from=P, horizon=H) |
| 21 | p4 = computeForecast(data, indices, "Persistence", "LastValue", |
| 22 | predict_from=P, horizon=H, same_day=TRUE) |
| 23 | -----r |
| 24 | e1 = computeError(data, p1, P, H) |
| 25 | e2 = computeError(data, p2, P, H) |
| 26 | e3 = computeError(data, p3, P, H) |
| 27 | e4 = computeError(data, p4, P, H) |
| 28 | options(repr.plot.width=9, repr.plot.height=7) |
| 29 | plotError(list(e1, e4, e3, e2), cols=c(1,2,colors()[258],4), agg="month") |
| 30 | |
| 31 | # noir: Neighbors non-local (p1), bleu: Neighbors local (p2), |
| 32 | # vert: moyenne (p3), rouge: persistence (p4) |