- yrange = range( sapply(1:L, function(i) ( err[[i]]$abs$day ) ), na.rm=TRUE )
- for (i in seq_len(L))
- {
- plot(err[[i]]$abs$day, type="l", xlab=ifelse(i==1,"Temps (heures)",""),
- ylab=ifelse(i==1,"Moyenne |y - y_hat|",""), ylim=yrange, col=cols[i])
- if (i < L)
- par(new=TRUE)
- }
- yrange = range( sapply(1:L, function(i) ( err[[i]]$abs$indices ) ), na.rm=TRUE )
- for (i in seq_len(L))
- {
- plot(err[[i]]$abs$indices, type="l", xlab=ifelse(i==1,"Temps (jours)",""),
- ylab=ifelse(i==1,"Moyenne |y - y_hat|",""), ylim=yrange, col=cols[i])
- if (i < L)
- par(new=TRUE)
- }
- yrange = range( sapply(1:L, function(i) ( err[[i]]$MAPE$day ) ), na.rm=TRUE )
- for (i in seq_len(L))
- {
- plot(err[[i]]$MAPE$day, type="l", xlab=ifelse(i==1,"Temps (heures)",""),
- ylab=ifelse(i==1,"MAPE moyen",""), ylim=yrange, col=cols[i])
- if (i < L)
- par(new=TRUE)
- }
- yrange = range( sapply(1:L, function(i) ( err[[i]]$MAPE$indices ) ), na.rm=TRUE )
- for (i in seq_len(L))
- {
- plot(err[[i]]$MAPE$indices, type="l", xlab=ifelse(i==1,"Temps (jours)",""),
- ylab=ifelse(i==1,"MAPE moyen",""), ylim=yrange, col=cols[i])
- if (i < L)
- par(new=TRUE)
- }
+
+ yrange = range( sapply(1:L, function(i) err[[i]]$abs$day), na.rm=TRUE )
+ matplot(sapply( seq_len(L), function(i) err[[i]]$abs$day ), type="l",
+ xlab="Time (hours)", ylab="Mean |y - y_hat|", ylim=yrange, col=cols, lwd=2, lty=1)
+
+ agg_curves <- sapply( seq_len(L), function(i) {
+ curve <- err[[i]]$abs$indices
+ delta <- if (agg=="day") 1 else if (agg=="week") 7 else if (agg=="month") 30
+ vapply( seq(1,length(curve),delta), function(i) {
+ mean(curve[i:(i+delta-1)], na.rm=TRUE)
+ }, vector("double",1), USE.NAMES=FALSE )
+ })
+ yrange = range(agg_curves, na.rm=TRUE)
+ matplot(agg_curves, type="l", xlab=paste("Time (",agg,"s)", sep=""),
+ ylab="Mean |y - y_hat|", ylim=yrange, col=cols, lwd=2, lty=1)
+
+ yrange = range( sapply(1:L, function(i) err[[i]]$MAPE$day), na.rm=TRUE )
+ matplot(sapply( seq_len(L), function(i) err[[i]]$MAPE$day ), type="l",
+ xlab="Time (hours)", ylab="Mean MAPE", ylim=yrange, col=cols, lwd=2, lty=1)
+
+ agg_curves <- sapply( seq_len(L), function(i) {
+ curve <- err[[i]]$MAPE$indices
+ delta <- if (agg=="day") 1 else if (agg=="week") 7 else if (agg=="month") 30
+ vapply( seq(1,length(curve),delta), function(i) {
+ mean(curve[i:(i+delta-1)], na.rm=TRUE)
+ }, vector("double",1), USE.NAMES=FALSE )
+ })
+ yrange = range(agg_curves, na.rm=TRUE)
+ matplot(agg_curves, type="l", xlab=paste("Time (",agg,"s)", sep=""),
+ ylab="Mean MAPE", ylim=yrange, col=cols, lwd=2, lty=1)