sse_wrapper.Rd
Wrapper around sse
sse_wrapper(v_calibrate, v, hydro_data, sse = TRUE)
v_calibrate | These values replace NA values in v |
---|---|
v | Model parameters as log(a), lob(b), log(d), log(C_d). Set to NA those which
should be replaced by |
hydro_data | data.frame containing |
sse | logical, if TRUE will return SSE. Otherwise, returns full data.frame of results |
This functions calculates SSE (sum of squared error), comparing modeled salinity output to the
calibration data (hydro_data$S_ppm
). Salinity is modeled using daily streamflow
(hydro_data$Q_cumec
) and the parameters v
-- and those values of v
that are
NA are replaced by values in v_calibrate
.
hydro_data <- ganges_streamflow v <- ganges_params$param # Output salinity in ppm hydro_data$S_ppm <- sim_salin_annual(hydro_data, v) # add random error to salinity output set.seed(100) hydro_data$S_ppm_orig <- hydro_data$S_ppm hydro_data$S_ppm <- hydro_data$S_ppm_orig * runif(nrow(hydro_data), min = 0.9, max = 1.1) hydro_data$year <- as.numeric(strftime(hydro_data$date,"%Y")) sse_all <- sse_wrapper(NULL, v, hydro_data) sse_all#> [1] 18414642hydro_data$Cvect <- sse_wrapper(NULL, v, hydro_data, FALSE)$Cvect sse_all_manual <- sum((hydro_data$S_ppm - hydro_data$Cvect)^2) sse_all_manual#> [1] 18414642#> [1] 130001190