knn_get_index_year: Get the index years using k-nearest neighbor method

View source: R/knn_get_index_year.R

knn_get_index_yearR Documentation

Get the index years using k-nearest neighbor method

Description

For an index gage, select the years that are closest to a flow that needs to be disaggregated, based on k-nearest neighbor selection.

Usage

knn_get_index_year(
  ann_flow,
  ann_index_flow,
  k_weights = knn_params_default(nrow(ann_index_flow)),
  random_seed = NULL
)

Arguments

ann_flow

A 2-column matrix, with years in column 1, and an annual flow in column 2. This is the annual flow that needs to be disaggregated.

ann_index_flow

A 2-column matrix, with years in column 1, and an annual flow in column 2. This is the index gage that the flows in ann_flow will be compared to. After the comparison, the nearest neighbor years are selected.

k_weights

A knn_params() object. By default, it uses knn_params_default().

random_seed

A single integer or NULL. If an integer, then it is used with set.seed() so reproducible results can be guaranteed.

Value

N x 1 matrix of index years, with the number of rows, equal to the number of rows in ann_flow.

References

Nowak, K., Prairie, J., Rajagopalan, B., Lall, U. (2010). A nonparametric stochastic approach for multisite disaggregation of annual to daily streamflow. Water Resources Research.

See Also

knn_params(), knn_params_default()

Examples

# a sample of three years of flow data
flow_mat <- cbind(c(2000, 2001, 2002), c(1400, 1567, 1325))
# made up historical data to use as index years
ind_flow <- cbind(1901:1980, rnorm(80, mean = 1500, sd = 300))
knn_get_index_year(flow_mat, ind_flow)


rabutler-usbr/knnstdisagg documentation built on Sept. 14, 2023, 2:47 p.m.