The coefficients calculated by Edwards (1997) and returned by edwards_coefs() were designed to produce reasonable results for several general cases, however each source water will have a set of empirical coefficients that produce more accurate predictions than the general case. This function calculates the optimal coefficients given a test set of known initial values (DOC)

fit_edwards_optim(
  data,
  initial_coefs = edwards_coefs("Al"),
  optim_params = list()
)

fit_edwards_coefs(coefs, data = edwards_data("empty"))

# S3 method for edwards_fit_optim
coef(object, ...)

# S3 method for edwards_fit_coefs
coef(object, ...)

# S3 method for edwards_fit_base
predict(object, newdata = NULL, ...)

coagulate_grid(
  object,
  DOC,
  UV254,
  dose = seq(0.01, 2, length.out = 50),
  pH = seq(5, 8, length.out = 50)
)

# S3 method for edwards_fit_base
fitted(object, ...)

# S3 method for edwards_fit_base
residuals(object, ...)

# S3 method for edwards_fit_base
tidy(x, ...)

# S3 method for edwards_fit_base
glance(x, ...)

# S3 method for edwards_fit_base
print(x, ...)

# S3 method for edwards_fit_base
plot(x, ...)

Arguments

data

A data frame with columns DOC (mg/L), dose (mmol/L), pH (pH units), UV254 (1/cm), and DOC_final (mg/L). See coagulate() for more information.

optim_params

Additional arguments to be passed to stats::optim().

coefs, initial_coefs

A set of initial coefficients from which to start the optimisation. Most usefully one of the coefficient sets returned by edwards_coefs().

object, x

A fit objected created with fit_edwards_optim().

...

Not used.

newdata

A data frame with columns DOC (mg/L), dose (mmol/L), pH (pH units), and UV254 (1/cm). If omitted, the data used to fit the model is used.

DOC

The initial DOC concentration (mg/L).

UV254

The absorbance of UV254 (1/cm). With DOC, used to calculate SUVA.

dose

The coagulant metal concentration (Al3+ or Fe3+) in mmol/L.

pH

The pH of coagulation.

Value

An S3 of type "edwards_fit_optim" with components:

data, initial_coefs, optim_params

References to inputs.

fit_optim

The fit object returned by stats::optim().