在“模拟”和“实测”两种条件下(见图),
我想计算一些错误指标,例如 Nash-Sutcliffe 效率 (NSE) 或均方根误差 (RMSE),但我不知道如何编写命令。有728个模拟值,而测量值只有30 个。有人可以帮我吗?谢谢!
library(readxl)
library(hydroGOF)
library(zoo)
X0_40cm <- read_excel("C:/Rstudy/For_10-40cm.xlsx")
data(X0_40cm)
使用以下代码计算NSE
并rmse
使用hydroGOF
包
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
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(foreign)
library(dplyr)
library(readxl)
library(scales)
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"))