##############################################################
y1 = 2+ 0.15*(1:20) + rnorm(20,2)
y2 = y1[20]+ 0.3*(1:30) + rnorm(30,2)
y = as.ts(c(y1,y2))
otm.fit <- otm(y=as.ts(y[1:40]), h=10)
plot(y)
points(otm.fit$fitted, type = "l")
points(otm.fit$mean, type = "l", col="blue")
theta.fit <- thetaM(y=as.ts(y[1:40]), h=10)
### sMAPE metric
errorMetric(obs=as.ts(y[41:50]), forec=otm.fit$mean, type = "sAPE", statistic = "M")
errorMetric(obs=as.ts(y[41:50]), forec=theta.fit$mean, type = "sAPE", statistic = "M")
### sMdAPE metric
errorMetric(obs=as.ts(y[41:50]), forec=otm.fit$mean, type = "sAPE", statistic = "Md")
errorMetric(obs=as.ts(y[41:50]), forec=theta.fit$mean, type = "sAPE", statistic = "Md")
### MASE metric
meanDiff1 = mean(abs(diff(as.ts(y[1:40]), lag = 1)))
errorMetric(obs=as.ts(y[41:50]), forec=otm.fit$mean, type = "AE", statistic = "M") / meanDiff1
errorMetric(obs=as.ts(y[41:50]), forec=theta.fit$mean, type = "AE", statistic = "M") / meanDiff1
Run the code above in your browser using DataLab