我有一个数据框如下。
RMSE MAE MPE MAPE
ARIMA(1, 1, 0)(1, 1, 1)23 540.4890 362.6894 -1.2617083 8.273222
ARIMA(1, 0, 0)(1, 1, 1)23 550.7088 373.4725 -0.9303624 8.523295
ARIMA(1, 1, 0)(2, 1, 1)23 539.1094 360.4556 -1.2885436 8.220159
ARIMA(2, 0, 0)(1, 1, 1)23 547.4179 366.4258 -0.9816881 8.374072
ARIMA(1, 0, 0)(2, 1, 1)23 548.6216 372.1675 -0.9249135 8.494618
我想将其绘制为一个表格,并希望在每一行中具有最小值的颜色。因此,我可以看到哪个模型在误差值方面提供了更好的结果。我找不到一个简单的方法来做到这一点。该表将通过R.Net上传到网站。我试过这个example,但我甚至没有通过第一部分。
# load Systematic Investor Toolbox
setInternet2(TRUE)
source(gzcon(url('https://github.com/systematicinvestor
数据:
structure(list(RMSE = c(540.489, 550.7088, 539.1094, 547.4179,
548.6216), MAE = c(362.6894, 373.4725, 360.4556, 366.4258, 372.1675
), MPE = c(-1.2617083, -0.9303624, -1.2885436, -0.9816881, -0.9249135
), MAPE = c(8.273222, 8.523295, 8.220159, 8.374072, 8.494618)), .Names =
c("RMSE",
"MAE", "MPE", "MAPE"), class = "data.frame", row.names = c("ARIMA(1,1,0)(1,1,1)23",
"ARIMA(1,0,0)(1,1,1)23", "ARIMA(1,1,0)(2,1,1)23", "ARIMA(2,0,0)(1,1,1)23",
"ARIMA(1,0,0)(2,1,1)23"))
答案 0 :(得分:1)
让dat
成为您的数据框,您可以这样做:
## colour setting for each row / model
col_set <- 1:5
## do matrix plot; extend `xlim` to the right to reserve space for legend
matplot(y = t(dat), xaxt = "n", pch = 19, col = col_set,
xlab = "", ylab = "Error", xlim = c(1, ncol(dat)+2L))
axis(1L, seq_len(ncol(dat)), colnames(dat))
## add legend at top right corner
legend("topright", legend = rownames(dat), pch = 19, col = col_set)
## highlight the column minimum
points(seq_len(ncol(dat)), unlist(lapply(dat, min)), cex = 2, pch = 19,
col = col_set[unlist(lapply(dat, which.min))])
正如您所观察到的,没有重新缩放,图形演示很差。我们现在将所有列缩放到[0, 1]
并制作图。
dat <- "rownames<-"(do.call(cbind.data.frame, lapply(dat, function (u) (u - min(u)) / diff(range(u)))),
rownames(dat))
# RMSE MAE MPE MAPE
#ARIMA(1,1,0)(1,1,1)23 0.1189372 0.1716077 0.07379835 0.1750468
#ARIMA(1,0,0)(1,1,1)23 1.0000000 1.0000000 0.98501527 1.0000000
#ARIMA(1,1,0)(2,1,1)23 0.0000000 0.0000000 0.00000000 0.0000000
#ARIMA(2,0,0)(1,1,1)23 0.7162870 0.4586499 0.84386716 0.5077358
#ARIMA(1,0,0)(2,1,1)23 0.8200597 0.8997457 1.00000000 0.9053989
然后使用以前的代码,我们有