Learn R Programming

hydroGOF (version 0.2-2)

ggof: Graphical Goodness of Fit

Description

Graphical comparison between two vectors (numeric, ts or zoo), with several numerical goodness of fit printed as a legend. Missing values in observed and/or simulated values can removed before the computations.

Usage

ggof(sim, obs, na.rm = TRUE, dates, date.fmt = "%Y-%m-%d", 
     pt.style = "ts", ftype = "o",  FUN, 
     gof.leg = TRUE,  digits=2, 
     legend=c("Sim", "Obs"), leg.cex=1,
     tick.tstep = "months", lab.tstep = "years", lab.fmt,
     cal.ini=NA, val.ini=NA,
     main, xlab = "Time", ylab=c("Q, [m3/s]"),  
     col = c("blue", "black"), 
     cex = c(0.5, 0.5), cex.axis=1.2, cex.lab=1.2,
     lwd = c(1, 1), lty = c(1, 3), pch = c(1, 9), ...)

Arguments

sim
numeric or zoo object with with simulated values
obs
numeric or zoo object with observed values
na.rm
a logical value indicating whether 'NA' should be stripped before the computation proceeds. When an 'NA' value is found at the i-th position in obs OR sim, the i-th value of obs AND sim ar
dates
character, factor or Date object indicating how to obtain the dates for the corresponding values in the sim and obs time series If dates is a character or factor, it is converted into Date class, using the date form
date.fmt
OPTIONAL. character indicating the format in which the dates are stored in dates, cal.ini and val.ini. See format in as.Date. Default value is %Y-%
pt.style
Character indicating if the 2 ts have to be plotted as lines or bars. When ftype is NOT o, it only applies for the annual values. Valid values are: -) ts : (default) each ts is plotted as a lines along the 'x' axis -)
ftype
Character indicating how many plots are desired by the user. Valid values are: -) o : only the original sim and obs time series are plotted -) dm : it assumes that sim and obs ar
FUN
OPTIONAL, ONLY required when ftype is in c('dm', 'ma', 'dma'). Function that have to be applied for transforming from daily to monthly or annual time step (e.g., for precipitation FUN MUST be sum, for temperature and
gof.leg
logical, indicating if several numerical goodness of fit have to be computed between sim and obs, and plotted as a legend on the graph. If leg.gof=TRUE, then x is considered as observed and y
digits
OPTIONAL, only used when leg.gof=TRUE. Numeric, representing the decimal places used for rounding the goodness-of-fit indexes.
legend
character of length 2 to appear in the legend.
leg.cex
OPTIONAL. ONLY used when leg.gof=TRUE. Character expansion factor for drawing the legend, *relative* to current 'par("cex")'. Used for text, and provides the default for 'pt.cex' and 'title.cex'. Default value = 1
tick.tstep
character, indicating the time step that have to be used for putting the ticks on the time axis. Valid values are: -) days, -) months, -) years
lab.tstep
character indicating the time step that have to be used for putting the labels on the time axis. Valid values are: -) days, -) months, -) years
lab.fmt
Character indicating with the format to be used for the label of the axis. See format in as.Date. If not specified, it will try "%Y-%m-%d" when lab.tstep=="days",
cal.ini
OPTIONAL. Character, indicating the date in which the calibration period started. ONLY used for drawing a vertical red line at this date.
val.ini
OPTIONAL. Character, the date in which the validation period started. ONLY used for drawing a vertical red line at this date.
main
character representing the main title of the plot.
xlab
label for the 'x' axis.
ylab
label for the 'y' axis.
col
character, representing the colors of sim and obs
cex
numeric, representing the values controlling the size of text and symbols of 'x' and 'y' with respect to the default
cex.axis
numeric, representing the magnification to be used for the axis annotation relative to 'cex'. See par.
cex.lab
numeric, representing the magnification to be used for x and y labels relative to the current setting of 'cex'. See par.
lwd
vector with the line width of sim and obs
lty
numeric with the line type of sim and obs
pch
numeric with the type of symbol for x and y. (e.g., 1: white circle; 9: white rhombus with a cross inside)
...
further arguments passed to or from other methods.

Value

  • meMean Error
  • maeMean Absolute Error
  • rmseRoot Mean Square Error
  • nrmseNormalized Root Mean Square Error
  • PBIASPercent Bias
  • pbiasfdcPBIAS in the slope of the midsegment of the Flow Duration Curve
  • RSRRatio of RMSE to the Standard Deviation of the Observations, RSR = rms / sd(obs). ( 0 <= rsr="" <="+Inf" )<="" description="">
  • rSDRatio of Standard Deviations, rSD = sd(sim) / sd(obs)
  • NSeffNash-Sutcliffe Efficiency ( -Inf <= nseff="" <="1" )<="" description="">
  • mNSeffModified Nash-Sutcliffe Efficiency
  • rNSeffRelative Nash-Sutcliffe Efficiency
  • dIndex of Agreement ( 0 <= d="" <="1" )<="" description="">
  • mdModified Index of Agreement
  • rdRelative Index of Agreement
  • cpPersistence Index ( 0 <= pi="" <="1" )<="" description="">
  • rPearson Correlation coefficient ( -1 <= r="" <="1" )<="" description="">
  • r.SpearmanSpearman Correlation coefficient ( -1 <= r.spearman="" <="1" )<="" description="">
  • R2Coefficient of Determination ( 0 <= r2="" <="1" ).="" gives="" the="" proportion="" of="" variance="" one="" variable="" that="" is="" predictable="" from="" other="" variable<="" description="">
  • bR2R2 multiplied by the coefficient of the regression line between sim and obs ( 0 <= br2="" <="1" )<="" description="">
  • KGEKling-Gupta efficiency between sim and obs ( 0 <= kge="" <="1" )<="" description="">

Details

Plots observed and simulated values in the same graph.

If gof.leg=TRUE, it computes the numerical values of: 'me', 'mae', 'rms', 'nrms', 'PBIAS', 'RSR, 'rSD', 'NSeff', 'mNSeff', 'rNSeff', 'd', 'md, 'rd', 'cp', 'r', 'r.Spearman', 'R2', 'bR2'

References

Legates, D. R., and G. J. McCabe Jr. (1999), Evaluating the Use of "Goodness-of-Fit" Measures in Hydrologic and Hydroclimatic Model Validation, Water Resour. Res., 35(1), 233--241 Krause P., Boyle D.P., and B"{a}se F., Comparison of different efficiency criteria for hydrological model assessment, Advances in Geosciences 5 (2005), pp. 89--97 Moriasi, D.N., Arnold, J.G., Van Liew, M.W., Bingner, R.L., Harmel, R.D., Veith, T.L. 2007. Model evaluation guidelines for systematic quantification of accuracy in watershed simulations Transactions of the ASABE. 50(3):885-900 Boyle, D. P., H. V. Gupta, and S. Sorooshian (2000), Toward Improved Calibration of Hydrologic Models: Combining the Strengths of Manual and Automatic Methods, Water Resour. Res., 36(12), 3663--3674 Kitanidis, P. K., and R. L. Bras (1980), Real-Time Forecasting With a Conceptual Hydrologic Model 2. Applications and Results, Water Resour. Res., 16(6), 1034--1044 J.E. Nash and J.V. Sutcliffe, River flow forecasting through conceptual models. Part 1: a discussion of principles, J. Hydrol. 10 (1970), pp. 282--290 Yapo P. O., Gupta H. V., Sorooshian S., 1996. Automatic calibration of conceptual rainfall-runoff models: sensitivity to calibration data. Journal of Hydrology. v181 i1-4. 23--48 Yilmaz, K. K., H. V. Gupta, and T. Wagener (2008), A process-based diagnostic approach to model evaluation: Application to the NWS distributed hydrologic model, Water Resour. Res., 44, W09417, doi:10.1029/2007WR006716

See Also

gof, plot2

Examples

Run this code
obs <- 1:10
sim <- 2:11

ggof(sim, obs)

##################
# Loading daily streamflows of the Ega River (Spain), from 1961 to 1970
require(zoo)
data(EgaEnEstellaQts)
obs <- EgaEnEstellaQts

# Generating a simulated daily time series, initially equal to the observed series
sim <- obs 

# Getting the numeric goodness of fit for the "best" (unattainable) case
gof(sim=sim, obs=obs)

# Randomly changing the first 2000 elements of 'sim', by using a normal distribution 
# with mean 10 and standard deviation equal to 1 (default of 'rnorm').
sim[1:2000] <- obs[1:2000] + rnorm(2000, mean=10)

# Getting the new numeric goodness of fit 
gof(sim=sim, obs=obs)

# Getting the graphical representation of 'obs' and 'sim' along with the numeric 
# goodness of fit for the daily and monthly time series 
require(hydroTSM)
ggof(sim=sim, obs=obs, ftype="dm", FUN=mean)

Run the code above in your browser using DataLab