This R package presents a Sliding Windows Regression model with Gaussian kernels for hydrological inference, see Schrunner et al. (2023). Given an input time series
A lagged time window
Instead of
- a location parameter
$$\delta = \frac{s_{\min} + s_{\max}}{2}$$ indicating the window center on the time axis, i.e. the distance between the window center and the estimated time point on the time axis, and - a size parameter
$$\sigma = \lceil \frac{s_{\max}-s_{\min}}{6} \rceil$$ defining the width of the window.
Given such a window
Overall, the predicted output
where
The core functionality of the package consists of functions train and predict, which perform the model fitting and forecasting steps, respectively. Further, functions for evaluating and plotting model results and parameters are provided.
The implementation builds on an S3 class SWR, which implements multiple generic functions, such as summary, plot, coef, dim, AIC, or BIC. Further, evaluation metrics can be computed using eval_all, which calls regression performance metrics rmse (root mean square error, RMSE), nrmse (normalized RMSE), r2 (coefficient of determination), as well as hydrological metrics nse (Nash-Sutcliffe efficiency) and kge (Kling-Gupta efficientcy). Plots are provided for the kernel vectors
A sample dataset sampleWatershed is contained in the package. The data originates from a real-world watershed in Cowichan, British Columbia, Canada and contains daily precipitation (input time series), as well as gauged runoff (output time series). Both time series cover a period of 39 hydrological years, starting on October 01, 1979.
This version of the R package can be installed as follows:
remotes::install_github("sschrunner/SlidingWindowReg", build_manual = TRUE, build_vignettes = TRUE)
- R (>= 3.5.0)
- combinat,
- dplyr,
- ggplot2,
- hydroGOF,
- knitr,
- lifecycle,
- methods,
- nloptr,
- rgenoud,
- parallel,
- pbapply,
- rdist,
- Rdpack (>= 0.7),
- stats
If you use SlidingWindowReg in a report or scientific publication, we would appreciate citations to the following preprint:
Schrunner, S. et al. (2023). A Gaussian Sliding Windows Regression Model for Hydrological Inference. arXiv.org (preprint), 2023, https://doi.org/10.48550/arXiv.2306.00453
Bibtex entry:
@misc{schrunner2023gaussian,
title={A Gaussian Sliding Windows Regression Model for Hydrological Inference},
author={Stefan Schrunner and Joseph Janssen and Anna Jenul and Jiguo Cao and Ali A. Ameli and William J. Welch},
year={2023},
howpublished={arXiv.org (preprint)},
eprint={2306.00453},
archivePrefix={arXiv},
primaryClass={stat.ME},
doi={10.48550/arXiv.2306.00453},
url={https://doi.org/10.48550/arXiv.2306.00453}
}
The implemented Gaussian Sliding Windows Regression model was developed in collaboration between
- Norwegian University of Life Sciences (NMBU), Ås, Norway,
- University of British Columbia (UBC), Vancouver, Canada, and
- Simon Fraser University (SFU), Burnaby, Canada
This package is currently under development. For issues, feel free to contact Stefan Schrunner.