Wrapper around sse

sse_wrapper(v_calibrate, v, hydro_data, sse = TRUE)

Arguments

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 v_calibrate

hydro_data

data.frame containing S_ppm, Q_cumec, and year columns

sse

logical, if TRUE will return SSE. Otherwise, returns full data.frame of results

Details

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.

Examples

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] 18414642
hydro_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
# Testing specific values sse_wrapper(NULL, c(-12,v[2:4]), hydro_data)
#> [1] 130001190