Daniel - 1 year ago 69

R Question

I'm struggling with a problem in R. I want to evaluate the best measure of prediction for a lot of time series with different methods, for example

`ME, RMSE, MAE, etc.`

The measured data are stored in a list, which saved these data frames:

`ME, RMSE, MAE`

`residuen_overall`

For example by the length of two (ME):

(-1+0.26) / 2 --> -0.37

`residuen_overall[[1]]`

# ME RMSE MAE MPE MAPE

#naive -1 10.15 3.93 -22.69 40.14

residuen_overall[[2]]

# ME RMSE MAE MPE MAPE

#naive 0.26 7.84 6.33 -3.1 19.61

My idea was to create a loop, but it is not working:

`methods <- list("ME", "RMSE", "MAE", "MPE", "MAPE")`

for(i in 1:length(residuen_overall)) {

cumsum(residuen_overall[[i]]$methods[i])

}

I hope someone can help me, please! :)

Answer Source

Here are your data (if you use `dput()`

in the future it will make it easier to reconstruct them for testing purposes):

```
residuen_overall <- list(
c(ME=-1,RMSE=10.16,MAE=3.93,MPE=-22.69,MAPE=40.14),
c(ME=0.26,RMSE=7.84,MAE=6.33,MPE=-3.1,MAPE=19.61))
```

"Summing up all the values and dividing by the length" is just computing the mean value.

Collect your lists into a matrix:

```
r2 <- do.call(rbind,residuen_overall)
```

Compute the mean of each column:

```
colMeans(r2)
## ME RMSE MAE MPE MAPE
## -0.370 9.000 5.130 -12.895 29.875
```

It's still not clear to me how this is going to help you figure out the best method ...