pb210_fit_exponential | R Documentation |
Fits the exponential model (y ~ exp(m * x + b)
), estimating parameters m
and b
using stats::nls()
. The log-linear version fits the model log(y) ~ x
using stats::lm()
, where the y-intercept is b
and the slope of the
line is m
. The log-linear version overestimates the importance of small
values but is widely used. NA and zero values are removed observation-wise
prior to fitting.
pb210_fit_exponential(x, y, subset = NULL) pb210_fit_loglinear(x, y, subset = NULL) pb210_fit_exponential_manual(m, b) pb210_fit_exponential_zero() pb210_fit_exponential_constant(value) ## S3 method for class 'exponential_manual' predict(object, newdata, ...) ## S3 method for class 'exponential_manual' coef(object, ...) ## S3 method for class 'lm_loglinear' predict(object, newdata, ...) ## S3 method for class 'lm_loglinear' coef(object, ...)
x |
An independent variable like depth or cumulative dry mass. |
y |
A dependent variable that responds exponentially to |
subset |
|
m, b, value |
Directly specify coefficients for a manual fit. |
object |
A model fit object. |
newdata |
A tibble with a column |
... |
Not used. |
A model object like that returned by stats::nls()
, with a
stats::predict()
method.
fake_depth <- 0:10 fake_pb210 <- exp(5 - fake_depth) + rnorm(11, sd = 0.005) fit_exp <- pb210_fit_exponential(fake_depth, fake_pb210) fit_loglinear <- pb210_fit_loglinear(fake_depth, fake_pb210) coefficients(fit_exp) coefficients(fit_loglinear) tibble::tibble( new_depth = 0:5, fitted_exp = predict(fit_exp, newdata = tibble::tibble(x = new_depth)), fitted_loglin = predict(fit_loglinear, newdata = tibble::tibble(x = new_depth)) )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.