Skip to content

Commit 8151824

Browse files
committed
Add README.
1 parent 03027cb commit 8151824

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Mass Balance Regression
2+
3+
This package implements the Mass-balance-adjusted regression algorithm for sub-annual streamflow reconstruction. The algorithm implements a penalty term to minimize the differences between the total seasonal flow reconstruction and the annual flow reconstruction. Details are presented in Nguyen et al (2020).
4+
5+
Currently the package is only available on GitHub, but it will be available on CRAN soon.
6+
7+
To install the development from GitHub
8+
9+
``` {.r}
10+
install.packages('remotes')
11+
remotes::install_github('ntthung/mbr')
12+
```
13+
14+
The package has two main functions, `mb_reconstruction()` for reconstruction, and `cv_mb()` for cross-validation.
15+
16+
Example reconstruction
17+
18+
``` {.r}
19+
fit <- mb_reconstruction(
20+
instQ = p1Seasonal,
21+
pc.list = pc3seasons,
22+
start.year = 1750,
23+
lambda = 1,
24+
log.trans = 1:3
25+
)
26+
```
27+
28+
Example cross-validation
29+
30+
``` {.r}
31+
# Create hold-out chunks
32+
set.seed(24)
33+
cvFolds <- make_Z(
34+
obs = 1922:2003,
35+
nRuns = 50,
36+
frac = 0.25,
37+
contiguous = TRUE
38+
)
39+
# Run cross validation
40+
cv <- cv_mb(
41+
instQ = p1Seasonal,
42+
pc.list = pc3seasons,
43+
cv.folds = cvFolds,
44+
start.year = 1750,
45+
lambda = 1,
46+
log.trans = 1:3,
47+
return.type = 'metric means'
48+
)
49+
# Round up to two decimal places
50+
cv[, (2:6) := lapply(.SD, round, digits = 2), .SDcols = 2:6][]
51+
```
52+
53+
Type \`browseVignettes('mbr') for details.
54+
55+
**References**
56+
57+
Nguyen, H. T. T., Galelli, S., Xu, C., & Buckley, B. (2020). Multi-Proxy, Multi-Season Streamflow Reconstruction with Mass Balance Adjustment. Earth and Space Science Open Archive, 22. <https://doi.org/10.1002/essoar.10504791.1>

0 commit comments

Comments
 (0)