2

I have 18 years daily simulated and observed data and i can calculate the RMSE using this code;

sqrt( mean( (df$simulated-df$observed)^2 , na.rm = TRUE ) )

But i have to calculate RMSE on different time series whole time period, Yearly, monthly, weekly and on seasonal time scale. Moreover, i would like to perform correlation coefficient, variance, bias and mean and put all result in one file.

Any help will be appreciated.

Tung
  • 26,371
  • 7
  • 91
  • 115
irfan
  • 45
  • 10

2 Answers2

1

You should checkout hydroTSM and hydroGOF packages. They should have everything you're looking for

Example:

    # Getting the new numeric goodness-of-fit measures
    gof(sim = Simulated, obs = Observed)

    # Plot 'obs' vs 'sim' for the daily,
    # monthly and annual time series 
    ggof(sim = Simulated, obs = Observed, ylab = "Q (ft3/day)",
         ftype = "dma", FUN = mean)

Daily, Monthly and Annual timescale simulation vs observation

    ggof(sim = Sim, obs = Obs, ylab = "Q (ft3/day)",
         ftype = "seasonal", FUN = mean)

Seasonal simulation vs observation

Tung
  • 26,371
  • 7
  • 91
  • 115
  • Yes, i am using hydroGOF package, would you like to share codes? – irfan Jul 08 '16 at 03:29
  • @ thecatalyst , How we can deal missing values in these codes because there are missing values both in simulated and observed data? – irfan Jul 08 '16 at 07:54
  • Take a look at Mauricio's code on his Github then include `na.rm = TRUE` where applicable [ggof.R](https://github.com/hzambran/hydroGOF/blob/master/R/ggof.R). That function calls several functions in [`hydroTSM` package](https://github.com/hzambran/hydroTSM/tree/master/R) – Tung Jul 08 '16 at 08:34
  • i am getting this error bu computing the Mauricio`s code, how to rectify these error [ Note: 'sim' & 'obs' are not zoo objects => 'ftype' was changed to 'o' ] Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' is a list, but does not have components 'x' and 'y' In addition: Warning messages: 1: 'rNSE' can not be computed: some elements in 'obs' are zero ! 2: 'rd' can not be computed: some elements in 'obs' are zero ! – irfan Jul 09 '16 at 09:07
0

If scaling is an issue then you'd be well advised to standardize and normalize your data beforehand. This can be done with dates by encoding them into a meaningful numeric representation.

You can extract most of the statistics you want from your fitted model's summary, which you can explore with str(). You can also get a lot of useful stats including RMSE from the Metrics package.

Hack-R
  • 22,422
  • 14
  • 75
  • 131