under the two conditions of "Simulated" and "Measured" (See the image),
I want to calculate some error metrics such as Nash-Sutcliffe efficiency (NSE) or root mean square error (RMSE), but I don't know how to code the command. There are 728 simulated values, while measured values only 30. Could anyone help me, please? Thank you!
library(readxl)
library(hydroGOF)
library(zoo)
X0_40cm <- read_excel("C:/Rstudy/For_10-40cm.xlsx")
data(X0_40cm)
Use the following code to calculate NSE
and rmse
with hydroGOF
package
library(hydroGOF)
NSE(df$Simulated, df$Measured, na.rm = T)
#[1] -37.85747
rmse(df$Simulated, df$Measured, na.rm = T)
#[1] 0.02561592
df = structure(list(Date = structure(c(1507852800, 1507939200, 1508025600,
1508112000, 1508198400, 1508284800, 1508371200, 1508457600, 1508544000,
1508630400, 1508716800, 1508803200, 1508889600, 1508976000),
class = c("POSIXct","POSIXt"), tzone = "UTC"),
Simulated = c(0.23375, 0.23175, 0.231, 0.2305, 0.2405, 0.24, 0.2385, 0.23675, 0.2355, 0.234, 0.23225, 0.23075, 0.2295, 0.2285),
Measured = c(NA, 0.273, NA, NA, 0.21311677200277, NA, NA, NA, NA, 0.229871184500008, NA, NA, 0.242, NA)),
row.names = c(NA, -14L), class = c("tbl_df", "tbl", "data.frame"))
df <- structure(list(Date = structure(c(1507852800, 1507939200, 1508025600, 1508112000, 1508198400, 1508284800, 1508371200, 1508457600, 1508544000, 1508630400, 1508716800, 1508803200, 1508889600, 1508976000), class = c("POSIXct","POSIXt"), tzone = "UTC"), Simulated = c(0.23375, 0.23175, 0.231, 0.2305, 0.2405, 0.24, 0.2385, 0.23675, 0.2355, 0.234, 0.23225, 0.23075, 0.2295, 0.2285), Measured = c(NA, 0.273, NA, NA, 0.21311677200277, NA, NA, NA, NA, 0.229871184500008, NA, NA, 0.242, NA)), row.names = c(NA, -14L), class = c("tbl_df", "tbl", "data.frame"))
View(df)
library(dplyr)
library(hydroGOF)
library(zoo)
Simulated <- df$Simulated
Measured <- df$Measured
Date <- df$Date
ggof(sim=Simulated, obs=Measured, na.rm = TRUE, dates = Date, date.fmt = "%Y-%m-%d",,
pt.style = "ts", ftype = "o", FUN,
stype="default",
gof.leg = TRUE, digits=2,
gofs=c("ME", "MAE", "RMSE", "NRMSE", "PBIAS", "RSR", "rSD", "NSE", "mNSE",
"rNSE", "d", "md", "rd", "r", "R2", "bR2", "KGE", "VE"),
col = c("black", "red"),
main="Try", #Provide the chart title here
xlab = "Time", #Change the x-axis title here
ylab=c("Q, [m3/s]"), #Change the y-axis title here
lwd = c(2, 1), #To change the line width
cex = c(1, 2)) #To change the size of the points