Skip to contents

Fit rating curve using loess smoother

Usage

rc_loess(
  discharge,
  stage,
  ...,
  data = NULL,
  degree = 2,
  span = 0.75,
  extrapolate = TRUE,
  variance = var_none()
)

Arguments

discharge

<data-masking> Discharge: a vector, or an expression evaluated in data, such as a column name.

stage

<data-masking> Stage: a vector, or an expression evaluated in data, such as a column name.

...

Must be empty. Present so that every argument after it has to be named in full.

data

Optional data frame in which discharge and stage are evaluated.

degree

Degree of local polynomials (1 or 2).

span

Smoothing parameter, passed to stats::loess().

extrapolate

Single logical; allow extrapolation beyond the observed stage range? Default is TRUE. If FALSE, predictions outside the range of the gaugings are NA. (This sets loess's surface to "direct" or "interpolate"; see stats::predict.loess().)

variance

[Experimental] How the variance of the gaugings about the curve is modelled: var_none() (or "none", the default), var_prop() (or "prop"), or var_spec() with the variances. See variance. Under var_prop() the loess curve is refitted in rounds, like the parametric fits.

Value

An rc_loess object; see rating_curve for its contents. A loess curve has no parameters, so curve_parameters is an empty list.

Examples

fit <- rc_loess(discharge, stage, data = thompson)
predict(fit, new_stage = c(1, 3, 6), conflev = 0.95)
#> # A tibble: 3 × 4
#>   stage   fit ci_lwr ci_upr
#>   <dbl> <dbl>  <dbl>  <dbl>
#> 1     1  250.   228.   273.
#> 2     3  823.   796.   850.
#> 3     6 2216.  2192.  2240.