The function provides the ability to do a weighted combination of runoff and/or discharge timeseries in HS object using user provided weights. Function can process several input weight sets.

combine_runoff(
  HS,
  weights,
  intercept = 0,
  bias = 0,
  drop = FALSE,
  monthly = FALSE
)

Arguments

HS

An HS object

weights

A vector of weights with the same length as the number of runoff timeseries in HS, or a list of weight vectors.

intercept

If weights are associated with an intercept, include it here. Default intercept = 0.

bias

Bias in percentage. Defaults to 0.

drop

Whether to remove source timeseries and replace them with combinations, or keep source timeseries and add combination as new column.

monthly

If provided weights are for each month, set to TRUE to apply weights separately for each month.

Value

Returns the input HS object where runoff timeseries is replaced by the the combined timeseries'.

Details

If a named list of weights is provided to the function, their names will be preserved in the combinations. Otherwise the combinations are named using a running number.

If intercept is provided, it is added to the combined timeseries. If bias is provided, the combined timeseries is adjusted by timeseries / (1-bias/100).

Note that if the timeseries of dates is different in each runoff timeseries in the input, the output includes only those dates which are present in every input timeseries.

The combination is only applied to columns runoff_ts, and discharge_ts. Columns observation_ts and control_ts are left untouched if present.

Examples

if (FALSE) { weights <- c(0.2,0.2,0.3,0.3,0) combined <- combine_runoff(HS, weights) listweights <- list(weights1 = c(0.2,0.2,0.3,0.3,0), weights2 = c(0.1,0.2,0.3,0.2,0.2), weights3 = c(0,0,0,0.5,0.5)) combined2 <- combine_runoff(HS, listweights) }