Learn R Programming

realTimeloads (version 1.0.0)

bootstrap_regression: Regression parameters estimated using bootstrap resampling

Description

Computes uncertainty in regression parameters of y(x) after Rustomji and Wilkinson (2008)

Usage

bootstrap_regression(Calibration, fit_eq, fit_glm = FALSE)

Value

list with bootstrap regression parameters and list output from stats::lm()

Arguments

Calibration

data frame with surrogate(s) followed by analyte in last column

fit_eq

equation used to fit y(x), string (e.g, "y ~ x + x2", "y ~ x", "log10(y)~x')

fit_glm

logical to use Generalized Linear Models for models with factor (i.e., categorical) predictors

Warning

User should inspect regression residuals and relevant statistics to ensure model form is reasonable, suggested reading: regression diagnostics in Statistical Methods in Water Resources (https://doi.org/10.3133/tm4a3).

One can call plot(fit) to view various regression diagnostic plots

Author

Daniel Livsey (2023) ORCID: 0000-0002-2028-6128

References

Rustomji, P., & Wilkinson, S. N. (2008). Applying bootstrap resampling to quantify uncertainty in fluvial suspended sediment loads estimated using rating curves. Water resources research, 44(9).https://doi.org/10.1029/2007WR006088

Helsel, D.R., Hirsch, R.M., Ryberg, K.R., Archfield, S.A., and Gilroy, E.J., 2020, #' Statistical methods in water resources: U.S. Geological Survey Techniques and Methods, book 4, chap. A3, 458 p. https://doi.org/10.3133/tm4a3

Examples

Run this code
# \donttest{
# linear model
x <- 1:10
y <- 0.5*x + 10
boot <- bootstrap_regression(data.frame(x,y),"y~x")
# polynomial model, call to I() needed for squaring x in equation string
x <- 1:10
y <- x + x^2
boot <- bootstrap_regression(data.frame(x,y),"y ~ x+I(x^2)")
# power law model
# BCF returned since y is transformed to log units
x <- 1:10
y <- x^0.3
boot <- bootstrap_regression(data.frame(x,y),"log10(y)~log10(x)")
# multivariate model
a <- 1:10
b <- a*2
c <- a^2*b^3
boot <- bootstrap_regression(data.frame(a,b,c),"log10(c)~log10(a)+log10(b)")
# }

Run the code above in your browser using DataLab