| Title: | Fits a Collection of Curves to Single-Cohort Decomposition Data |
|---|---|
| Description: | Fit different model forms to single-cohort litter decomposition data (mass remaining through time) using likelihood-based estimation. Models span simple empirical to process-motivated forms with differing numbers of free parameters. Provides parameter estimates, uncertainty, and tools for model comparison/selection. Based on Cornwell & Weedon (2013) <doi:10.1111/2041-210X.12138>. |
| Authors: | Will Cornwell [aut, cre] (ORCID: <https://orcid.org/0000-0003-4080-4073>), James Weedon [aut], Guofang Liu [ctb] |
| Maintainer: | Will Cornwell <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.3.0 |
| Built: | 2026-11-23 04:41:42 UTC |
| Source: | https://github.com/cran/litterfitter |
Combine existing fits into a litfit_list
as_litfit_list(...)as_litfit_list(...)
... |
|
Information criteria are only comparable between fits to the same data, so a warning is given if the fits were made to different data.
A litfit_list.
f1 <- fit_litter(pineneedles$Year, pineneedles$Mass.remaining, "neg.exp", iters = 50, quiet = TRUE ) f2 <- fit_litter(pineneedles$Year, pineneedles$Mass.remaining, "weibull", iters = 50, quiet = TRUE ) fits <- as_litfit_list(f1, f2) glance(fits)f1 <- fit_litter(pineneedles$Year, pineneedles$Mass.remaining, "neg.exp", iters = 50, quiet = TRUE ) f2 <- fit_litter(pineneedles$Year, pineneedles$Mass.remaining, "weibull", iters = 50, quiet = TRUE ) fits <- as_litfit_list(f1, f2) glance(fits)
Create a bootstrap distribution of a particular coefficient from a model fit
bootstrap_parameters(x,nboot,upper,lower,...)bootstrap_parameters(x,nboot,upper,lower,...)
x |
an object of class " |
nboot |
number of bootstrap replications |
upper |
optional vector of upper bounds for the bootstrap replicates |
lower |
optional vector of lower bounds for the bootstrap replicates |
... |
passed to |
a litfit_bootstrap object: a matrix with one row per bootstrap
replicate and one column per parameter, plus derived quantities: the implied
steady state for a litfit, or the peak element remaining and the mass
remaining at the peak for an elementfit.
Failed replicates are recorded as NA.
fit <- fit_litter( time = pineneedles$Year, mass.remaining = pineneedles$Mass.remaining, model = "neg.exp", iters = 100 ) boot1 <- bootstrap_parameters(fit, nboot = 500)fit <- fit_litter( time = pineneedles$Year, mass.remaining = pineneedles$Mass.remaining, model = "neg.exp", iters = 100 ) boot1 <- bootstrap_parameters(fit, nboot = 500)
Methods for element fits from fit_element. The predictor is proportional
mass remaining, so newdata gives mass remaining values.
## S3 method for class 'elementfit' print(x, ...) ## S3 method for class 'elementfit' coef(object, ...) ## S3 method for class 'elementfit' fitted(object, ...) ## S3 method for class 'elementfit' residuals(object, ...) ## S3 method for class 'elementfit' nobs(object, ...) ## S3 method for class 'elementfit' logLik(object, ...) ## S3 method for class 'elementfit' predict(object, newdata = NULL, ...) ## S3 method for class 'elementfit' tidy(x, boot = NULL, conf.level = 0.95, ...) ## S3 method for class 'elementfit' glance(x, ...) ## S3 method for class 'elementfit' augment(x, newdata = NULL, boot = NULL, conf.level = 0.95, ...)## S3 method for class 'elementfit' print(x, ...) ## S3 method for class 'elementfit' coef(object, ...) ## S3 method for class 'elementfit' fitted(object, ...) ## S3 method for class 'elementfit' residuals(object, ...) ## S3 method for class 'elementfit' nobs(object, ...) ## S3 method for class 'elementfit' logLik(object, ...) ## S3 method for class 'elementfit' predict(object, newdata = NULL, ...) ## S3 method for class 'elementfit' tidy(x, boot = NULL, conf.level = 0.95, ...) ## S3 method for class 'elementfit' glance(x, ...) ## S3 method for class 'elementfit' augment(x, newdata = NULL, boot = NULL, conf.level = 0.95, ...)
x, object
|
an |
... |
unused |
newdata |
optional numeric vector of mass remaining values, or (for
|
boot |
optional |
conf.level |
confidence level for intervals and bands |
glance() reports, besides information criteria, the peak proportional element
remaining (peak_element) and the mass remaining at which it occurs
(mass_at_peak). A peak of 1 at a mass of 1 means no net immobilisation.
tidy(), glance() and augment() return a data.frame
(see litfit_tidiers for the shared columns; augment() uses
mass and element columns). plot() and print() return
x invisibly.
fit <- fit_element( mass.remaining = pineneedles$Mass.remaining, element.remaining = c(1.1, 1.2, 1.3, 1, 0.8, 0.6), iters = 200, quiet = TRUE ) coef(fit) predict(fit, newdata = c(1, 0.75, 0.5, 0.25)) tidy(fit) glance(fit) head(augment(fit, newdata = seq(1, 0, by = -0.1)))fit <- fit_element( mass.remaining = pineneedles$Mass.remaining, element.remaining = c(1.1, 1.2, 1.3, 1, 0.8, 0.6), iters = 200, quiet = TRUE ) coef(fit) predict(fit, newdata = c(1, 0.75, 0.5, 0.25)) tidy(fit) glance(fit) head(augment(fit, newdata = seq(1, 0, by = -0.1)))
Fits a curve describing how the proportion of an element remaining (for example
nitrogen, ) changes with the proportion of litter mass remaining
() in a single decomposition cohort. Elements are often immobilised early in
decomposition (element remaining rises above 1) and released later.
fit_element( mass.remaining, element.remaining, model = c("import.model"), iters = 500, upper = NULL, lower = NULL, quiet = FALSE, ... )fit_element( mass.remaining, element.remaining, model = c("import.model"), iters = 500, upper = NULL, lower = NULL, quiet = FALSE, ... )
mass.remaining |
proportional mass remaining, |
element.remaining |
proportional element remaining, |
model |
the element model; currently only |
iters |
number of random starts for the fitting |
upper, lower
|
optional bounds for the parameters, in the order given in Details |
quiet |
if |
... |
additional arguments passed to |
import.model is the nitrogen release model of Parton et al. (2007), written
here for proportional mass remaining :
so the curve passes through 1 at (no mass lost). (bounds 0.01–1)
sets the mass remaining around which the immobilisation peak is centred, and
(bounds 0.1–10) controls the height and width of the peak; small gives a
tall, narrow peak. The original formulation used percent mass remaining (normalised
at 100, with between 1 and 100); this version is equivalent with
divided by 100.
Fitting uses the same multi-start likelihood approach as fit_litter, and
gives the same warnings for parameters on a boundary and for mass values outside 0–1.
An elementfit object, with methods for print, plot,
coef, fitted, residuals, predict, nobs,
logLik (so AIC() and BIC() work), tidy, glance
and augment, and support in bootstrap_parameters. Its elements
include optimFit, logLik, fitAIC, fitAICc,
fitBIC, mass, element, predicted, model and
nparams.
Baptiste Wijas, Will Cornwell
Parton, W., Silver, W. L., Burke, I. C., et al. (2007) Global-scale similarities in nitrogen release patterns during long-term decomposition. Science, 315, 361–364.
fit_litter for mass loss through time,
elementfit_methods, bootstrap_parameters
fit <- fit_element( mass.remaining = pineneedles$Mass.remaining, element.remaining = c(1.1, 1.2, 1.3, 1, 0.8, 0.6), iters = 200, quiet = TRUE ) fit plot(fit) glance(fit)fit <- fit_element( mass.remaining = pineneedles$Mass.remaining, element.remaining = c(1.1, 1.2, 1.3, 1, 0.8, 0.6), iters = 200, quiet = TRUE ) fit plot(fit) glance(fit)
Non-linear fits of different models to the decomposition trajectory of one cohort (as in typical litterbag studies) data. Models range from very simple (and easy to fit with limited data) to more complex.
fit_litter( time, mass.remaining, model = c("neg.exp", "weibull", "discrete.parallel", "discrete.series", "cont.quality", "neg.exp.limit"), iters = 500, upper = NULL, lower = NULL, quiet = FALSE, ... )fit_litter( time, mass.remaining, model = c("neg.exp", "weibull", "discrete.parallel", "discrete.series", "cont.quality", "neg.exp.limit"), iters = 500, upper = NULL, lower = NULL, quiet = FALSE, ... )
time |
time since decomposition began, that is, ti-t0 |
mass.remaining |
proportional mass remaining, that is, mi/m0. Values above 1 (apparent mass gain, up to 2) or slightly below 0 (down to -0.1) are kept and treated as measurement error, with an informative warning (see Details). |
model |
there are six models currently implemented (see below); defaults to |
iters |
Number of random starts for the fitting. Use higher numbers for models with larger numbers of parameters and for models that inherently tend to be less identifiable. |
upper, lower
|
Optional user specified values for the upper and lower bounds used by
|
quiet |
if |
... |
Additional arguments passed to |
the model likelihood is maximized using methods available in optim. Optimization methods to be used within optim can be specified through the control object (i.e., control$method). The default method is L-BFGS-B with bounds specific to each model. Each model
neg.exp The classic negative exponential model–one parameter (Olson 1963)
weibull The Weibull residence time model–two parameters (Frechet 1927)
discrete.parallel Two pools in parallel with a term for the fraction of initial mass in each pool–three parameter (Manzoni et al. 2012)
discrete.series A three parameter model in which there is the possibility of two sequential pools (Manzoni et al. 2012)
cont.quality (Ågren and Bosatta 1996, see also Manzoni et al. 2012)
neg.exp.limit A negative exponential decaying towards a non-zero asymptote ()–three parameters
Warning: difficulty in finding the optimal solution is determined by an interaction between the nature and complexity of the likelihood space (which is both data- and model-dependent) as well as the optimization methods. There can never be a guarantee that the optimal solution is found, but using many random starting points will increase these odds. It should be noted that there is significant variation among models in identifiability, with some models inherently less identifiable likely due to a tendency to form for flat ridges in likelihood space. The confidence in the fit should be very low in these cases (see Cornwell and Weedon 2013). A number of random starting points are used in optimization and are given through the iters. The function checks whether the best 5 optimizations have converged on the same likelihood, and if they have not this function will return a warning.
Values outside 0–1: measurement error, especially early in decomposition or when
decomposition is slow, can produce proportional mass remaining values slightly above 1
(i.e. negative mass loss). These values are kept in the fit, since removing or truncating
them would bias the estimates, but fit_litter warns (class
litterfitter_mass_above_one). If the data also show little overall mass loss, the
warning notes that parameters may be poorly constrained and that derived quantities such as
time_to_prop_mass_remaining and steady_state are extrapolations.
Slightly negative values (down to -0.1) are similarly kept with a warning (class
litterfitter_mass_below_zero). Use suppressWarnings(..., classes = ...) to
silence these once checked.
returns a litfit object with the following elements:
optimFit: a list generated by the optim function
logLik: the log-likelihood of the model
time: vector of time (same as input)
mass: vector of mass remaining (same as input)
predicted: predicted values from the model for each of the points within time
model: name of the model
nparams: number of fit parameters in the model
AIC: AIC of the model fit
AICc: AICc of the model fit
BIC: BIC of the model fit
and some other potentially useful things
Will Cornwell and James Weedon
Ågren, G. and Bosatta, E. (1996) Quality: a bridge between theory and experiment in soil organic matter studies. Oikos, 76, 522–528.
Cornwell, W. K., and J. T. Weedon. (2013). Decomposition trajectories of diverse litter types: a model selection analysis. Methods in Ecology and Evolution.
Frechet, M. (1927) Sur la loi de probabilite de lecart maximum. Ann de la Soc polonaise de Math, 6, 93–116.
Manzoni, S., Pineiro, G., Jackson, R. B., Jobbagy, E. G., Kim, J. H., & Porporato, A. (2012). Analytical models of soil and litter decomposition: Solutions for mass loss and time-dependent decay rates. Soil Biology and Biochemistry, 50, 66-76.
Olson, J.S. (1963) Energy storage and the balance of producers and decomposers in ecological systems. Ecology, 44, 322–331.
optim,
steady_state,
plot.litfit
data(pineneedles) fit <- fit_litter( time = pineneedles$Year, mass.remaining = pineneedles$Mass.remaining, model = "neg.exp", iters = 1000 )data(pineneedles) fit <- fit_litter( time = pineneedles$Year, mass.remaining = pineneedles$Mass.remaining, model = "neg.exp", iters = 1000 )
Fits each of the requested models with fit_litter and returns them
together as a litfit_list, ready for model comparison with
glance, tidy or
augment.
fit_litter_all( time, mass.remaining, models = c("neg.exp", "weibull", "discrete.parallel", "discrete.series", "cont.quality", "neg.exp.limit"), iters = 500, ... )fit_litter_all( time, mass.remaining, models = c("neg.exp", "weibull", "discrete.parallel", "discrete.series", "cont.quality", "neg.exp.limit"), iters = 500, ... )
time |
time since decomposition began |
mass.remaining |
proportional mass remaining |
models |
models to fit (see |
iters |
number of random starts for each model |
... |
further arguments passed to |
Warnings about the data (for example values above 1, or missing values removed) are given once rather than once per model. Warnings specific to one model, such as parameters on a boundary, are prefixed with the model name. A model that cannot be fitted (for example, too few observations for its number of parameters) is dropped with a warning; an error is raised only if no model can be fitted.
A litfit_list: a named list of litfit objects.
as_litfit_list to combine existing fits,
litfit_list_methods
fits <- fit_litter_all( time = pineneedles$Year, mass.remaining = pineneedles$Mass.remaining, models = c("neg.exp", "weibull", "cont.quality"), iters = 100 ) fits glance(fits)fits <- fit_litter_all( time = pineneedles$Year, mass.remaining = pineneedles$Mass.remaining, models = c("neg.exp", "weibull", "cont.quality"), iters = 100 ) fits glance(fits)
Model comparison tools for several fits to the same data, as returned by
fit_litter_all or as_litfit_list.
## S3 method for class 'litfit_list' print(x, ...) ## S3 method for class 'litfit_list' glance(x, ...) ## S3 method for class 'litfit_list' tidy(x, ...) ## S3 method for class 'litfit_list' augment(x, newdata = NULL, boot = NULL, conf.level = 0.95, ...) ## S3 method for class 'litfit_list' coef(object, ...) ## S3 method for class 'litfit_list' x[i]## S3 method for class 'litfit_list' print(x, ...) ## S3 method for class 'litfit_list' glance(x, ...) ## S3 method for class 'litfit_list' tidy(x, ...) ## S3 method for class 'litfit_list' augment(x, newdata = NULL, boot = NULL, conf.level = 0.95, ...) ## S3 method for class 'litfit_list' coef(object, ...) ## S3 method for class 'litfit_list' x[i]
x |
a |
... |
unused |
newdata |
optional times at which to predict (see |
boot |
optional named list of |
conf.level |
confidence level for bands (default 0.95) |
object |
a |
i |
indices or names of fits to keep |
glance(): one row per fit, sorted by AICc, with delta_AICc
(difference from the best model).
tidy(): parameter estimates for every fit.
augment(): fitted values (or predictions at newdata) for every fit,
stacked, for plotting.
Every table starts with a fit column holding the names of the list.
glance(), tidy() and augment() return a data.frame;
coef() returns a named list of parameter vectors; [ returns a
litfit_list.
fits <- fit_litter_all( time = pineneedles$Year, mass.remaining = pineneedles$Mass.remaining, models = c("neg.exp", "weibull"), iters = 100 ) glance(fits) tidy(fits) head(augment(fits, newdata = seq(0, 5, by = 0.5))) coef(fits) fits["weibull"]fits <- fit_litter_all( time = pineneedles$Year, mass.remaining = pineneedles$Mass.remaining, models = c("neg.exp", "weibull"), iters = 100 ) glance(fits) tidy(fits) head(augment(fits, newdata = seq(0, 5, by = 0.5))) coef(fits) fits["weibull"]
These methods return the results of a fit_litter fit as data frames,
following the conventions of the broom package.
## S3 method for class 'litfit' tidy(x, boot = NULL, conf.level = 0.95, ...) ## S3 method for class 'litfit' glance(x, ...) ## S3 method for class 'litfit' augment(x, newdata = NULL, boot = NULL, conf.level = 0.95, ...)## S3 method for class 'litfit' tidy(x, boot = NULL, conf.level = 0.95, ...) ## S3 method for class 'litfit' glance(x, ...) ## S3 method for class 'litfit' augment(x, newdata = NULL, boot = NULL, conf.level = 0.95, ...)
x |
a |
boot |
optional |
conf.level |
confidence level for intervals and bands (default 0.95) |
... |
unused |
newdata |
optional numeric vector of times, or a data frame with a |
tidy(): one row per parameter.
glance(): a one-row summary of the fit, including information criteria and
the derived quantities time to 50\
augment(): the data with fitted values and residuals, or predictions at
new time points, optionally with a bootstrap uncertainty band.
A data.frame.
tidy()term, estimate; with boot also
std.error, conf.low, conf.high.
glance()model, nobs, nparams, sigma
(residual standard deviation used in the likelihood), logLik, AIC,
AICc, BIC, converged, time_to_50, steady_state.
time_to_50 is NA if the curve never reaches 50\
steady_state can be Inf (see steady_state).
augment()without newdata: time, mass,
.fitted, .resid. With newdata: the columns of newdata
(or time) plus .fitted. With boot: also .lower and
.upper.
fit_litter, bootstrap_parameters,
fit_litter_all
fit <- fit_litter( time = pineneedles$Year, mass.remaining = pineneedles$Mass.remaining, model = "weibull", iters = 100, quiet = TRUE ) tidy(fit) glance(fit) augment(fit) boot <- bootstrap_parameters(fit, nboot = 100) tidy(fit, boot = boot) head(augment(fit, newdata = seq(0, 5, by = 0.5), boot = boot))fit <- fit_litter( time = pineneedles$Year, mass.remaining = pineneedles$Mass.remaining, model = "weibull", iters = 100, quiet = TRUE ) tidy(fit) glance(fit) augment(fit) boot <- bootstrap_parameters(fit, nboot = 100) tidy(fit, boot = boot) head(augment(fit, newdata = seq(0, 5, by = 0.5), boot = boot))
There is a long tradition of studying the flux of carbon from the biosphere to the atmosphere by following a particular cohort of litter (wood, leaves, roots, or other organic material) through time. The resulting data are mass remaining and time. A variety of functional forms may be used to fit the resulting data. Some work better empirically. Some are better connected to a process-based understanding. Some have a small number of free parameters; others have more. This package matches decomposition data to a set of these curves using likelihood–based fitting.
Maintainer: Will Cornwell [email protected] (ORCID)
Authors:
Will Cornwell [email protected] (ORCID)
James Weedon
Other contributors:
Guofang Liu [contributor]
Cornwell, W. K., and J. T. Weedon. (2013). Decomposition trajectories of diverse litter types: a model selection analysis. Methods in Ecology and Evolution.
Manzoni, S., Pineiro, G., Jackson, R. B., Jobbagy, E. G., Kim, J. H., & Porporato, A. (2012). Analytical models of soil and litter decomposition: Solutions for mass loss and time-dependent decay rates. Soil Biology and Biochemistry, 50, 66-76.
Useful links:
Report bugs at https://github.com/traitecoevo/litterfitter/issues
autoplot() methods that draw fits, model comparisons and bootstrap
distributions with ggplot2. They require ggplot2 to be installed and loaded
(library(ggplot2)); the result is a regular ggplot object that can be modified
with further layers, scales and themes.
## S3 method for class 'litfit' autoplot(object, boot = NULL, conf.level = 0.95, equation = TRUE, n = 200, ...) ## S3 method for class 'elementfit' autoplot(object, boot = NULL, conf.level = 0.95, equation = TRUE, n = 200, ...) ## S3 method for class 'litfit_list' autoplot(object, boot = NULL, conf.level = 0.95, n = 200, ...) ## S3 method for class 'litfit_bootstrap' autoplot(object, terms = NULL, conf.level = 0.95, ...)## S3 method for class 'litfit' autoplot(object, boot = NULL, conf.level = 0.95, equation = TRUE, n = 200, ...) ## S3 method for class 'elementfit' autoplot(object, boot = NULL, conf.level = 0.95, equation = TRUE, n = 200, ...) ## S3 method for class 'litfit_list' autoplot(object, boot = NULL, conf.level = 0.95, n = 200, ...) ## S3 method for class 'litfit_bootstrap' autoplot(object, terms = NULL, conf.level = 0.95, ...)
object |
a |
boot |
optional |
conf.level |
confidence level for bands and shaded intervals (default 0.95) |
equation |
if |
n |
number of points used to draw curves |
... |
unused |
terms |
for bootstraps, the parameters or derived quantities to show (default all) |
litfit: the data, fitted curve and (optionally) a bootstrap band, with
the fitted equation as the subtitle.
elementfit: as above, with mass remaining decreasing from left to right
and a dashed line at the initial element amount.
litfit_list: the curves of all models, coloured with the Okabe-Ito
palette and labelled with their difference in AICc from the best model ("delta AICc").
litfit_bootstrap: the bootstrap distribution of each parameter and
derived quantity in its own panel, with the central interval shaded and lines at
the mean (red) and median (blue).
a ggplot object
augment.litfit and tidy.litfit_bootstrap, which
return the data behind these plots for building custom figures;
plot.litfit for base graphics
library(ggplot2) fit <- fit_litter( time = pineneedles$Year, mass.remaining = pineneedles$Mass.remaining, model = "weibull", iters = 100, quiet = TRUE ) boot <- bootstrap_parameters(fit, nboot = 200) autoplot(fit, boot = boot) autoplot(boot) fits <- fit_litter_all(pineneedles$Year, pineneedles$Mass.remaining, models = c("neg.exp", "weibull", "cont.quality"), iters = 100 ) autoplot(fits) + theme_bw()library(ggplot2) fit <- fit_litter( time = pineneedles$Year, mass.remaining = pineneedles$Mass.remaining, model = "weibull", iters = 100, quiet = TRUE ) boot <- bootstrap_parameters(fit, nboot = 200) autoplot(fit, boot = boot) autoplot(boot) fits <- fit_litter_all(pineneedles$Year, pineneedles$Mass.remaining, models = c("neg.exp", "weibull", "cont.quality"), iters = 100 ) autoplot(fits) + theme_bw()
Returns the log-likelihood of the fitted model, which allows the standard
AIC and BIC functions to be used to
compare several litfit objects, e.g. AIC(fit1, fit2).
## S3 method for class 'litfit' logLik(object, ...)## S3 method for class 'litfit' logLik(object, ...)
object |
a |
... |
unused |
The degrees of freedom are the number of fitted curve parameters
(the residual standard deviation is not counted), consistent with the
fitAIC, fitAICc and fitBIC values stored in the object
and with Cornwell & Weedon (2013).
an object of class logLik
data from Hobbie et al means of pine needle decomposition
data(pineneedles)data(pineneedles)
a data.frame with two columns
Will Cornwell
Hobbie et al.
Fits several models to the same data with fit_litter_all and plots them
together with plot.litfit_list. Existing fits can be plotted instead
by passing a litfit_list (or a list of litfit objects) as the first
argument, which avoids refitting.
plot_multiple_fits( time, mass.remaining, model = c("neg.exp", "weibull", "discrete.parallel", "discrete.series", "cont.quality", "neg.exp.limit"), color = NULL, iters = 500, bty = "o", ... )plot_multiple_fits( time, mass.remaining, model = c("neg.exp", "weibull", "discrete.parallel", "discrete.series", "cont.quality", "neg.exp.limit"), color = NULL, iters = 500, bty = "o", ... )
time |
vector of time points, or a |
mass.remaining |
vector of mass remaining (ignored when |
model |
vector of models to fit and plot (see |
color |
colours for the curves; defaults to the Okabe-Ito palette |
iters |
number of random starts, passed to |
bty |
box type of the legend |
... |
additional arguments passed to |
the fits, invisibly, as a litfit_list
Liu Guofang
fit_litter_all, plot.litfit_list
plot_multiple_fits( time = pineneedles$Year, mass.remaining = pineneedles$Mass.remaining, bty = "n", model = c("neg.exp", "weibull"), iters = 200 ) # plot existing fits without refitting fits <- fit_litter_all(pineneedles$Year, pineneedles$Mass.remaining, models = c("neg.exp", "cont.quality"), iters = 100 ) plot_multiple_fits(fits)plot_multiple_fits( time = pineneedles$Year, mass.remaining = pineneedles$Mass.remaining, bty = "n", model = c("neg.exp", "weibull"), iters = 200 ) # plot existing fits without refitting fits <- fit_litter_all(pineneedles$Year, pineneedles$Mass.remaining, models = c("neg.exp", "cont.quality"), iters = 100 ) plot_multiple_fits(fits)
Plots proportional element remaining against proportional mass remaining, with mass remaining decreasing from left to right so that decomposition proceeds along the x axis. A dashed line marks the initial amount of the element.
## S3 method for class 'elementfit' plot(x, formulae.cex = 1, boot = NULL, conf.level = 0.95, ...)## S3 method for class 'elementfit' plot(x, formulae.cex = 1, boot = NULL, conf.level = 0.95, ...)
x |
an |
formulae.cex |
size of the parameter text; use |
boot |
optional |
conf.level |
confidence level for the band (default 0.95) |
... |
additional arguments passed to |
x, invisibly
fit <- fit_element( mass.remaining = pineneedles$Mass.remaining, element.remaining = c(1.1, 1.2, 1.3, 1, 0.8, 0.6), iters = 200, quiet = TRUE ) plot(fit)fit <- fit_element( mass.remaining = pineneedles$Mass.remaining, element.remaining = c(1.1, 1.2, 1.3, 1, 0.8, 0.6), iters = 200, quiet = TRUE ) plot(fit)
Plots the data and fitted curve from a litfit object, with the fitted equation.
If a bootstrap is supplied, a pointwise percentile band for the curve is added.
## S3 method for class 'litfit' plot(x, formulae.cex = 1, boot = NULL, conf.level = 0.95, ...)## S3 method for class 'litfit' plot(x, formulae.cex = 1, boot = NULL, conf.level = 0.95, ...)
x |
a |
formulae.cex |
size of the equation text; use |
boot |
optional |
conf.level |
confidence level for the band (default 0.95) |
... |
additional arguments passed to |
x, invisibly
Will Cornwell
fit_litter, plot.litfit_list;
autoplot() methods for ggplot2 output (litterfitter_autoplot)
fit <- fit_litter( time = pineneedles$Year, mass.remaining = pineneedles$Mass.remaining, model = "weibull", iters = 100, quiet = TRUE ) plot(fit) boot <- bootstrap_parameters(fit, nboot = 100) plot(fit, boot = boot, main = "Weibull fit with 95% band")fit <- fit_litter( time = pineneedles$Year, mass.remaining = pineneedles$Mass.remaining, model = "weibull", iters = 100, quiet = TRUE ) plot(fit) boot <- bootstrap_parameters(fit, nboot = 100) plot(fit, boot = boot, main = "Weibull fit with 95% band")
Plots the density of the bootstrap distribution of one or more parameters (or derived
quantities) from bootstrap_parameters.
## S3 method for class 'litfit_bootstrap' plot(x, coef.index = 1, bw = "nrd0", conf.level = 0.95, ...)## S3 method for class 'litfit_bootstrap' plot(x, coef.index = 1, bw = "nrd0", conf.level = 0.95, ...)
x |
a |
coef.index |
which column(s) to plot: a number, a column name such as |
bw |
bandwidth (or bandwidth rule, see |
conf.level |
width of the shaded central interval (default 0.95) |
... |
additional arguments passed to |
The grey fill covers the central conf.level interval of the
distribution. The red dashed line shows the mean and the blue dashed line the median.
Non-finite values (e.g. an infinite steady state) and failed replicates are ignored.
x, invisibly
James Weedon
fit <- fit_litter( time = pineneedles$Year, mass.remaining = pineneedles$Mass.remaining, model = "weibull", iters = 100, quiet = TRUE ) boot <- bootstrap_parameters(fit, nboot = 200) plot(boot) plot(boot, coef.index = "all")fit <- fit_litter( time = pineneedles$Year, mass.remaining = pineneedles$Mass.remaining, model = "weibull", iters = 100, quiet = TRUE ) boot <- bootstrap_parameters(fit, nboot = 200) plot(boot) plot(boot, coef.index = "all")
Plots the data with the fitted curve of every model in a litfit_list, and a
legend table of AIC, AICc and BIC sorted by AICc.
## S3 method for class 'litfit_list' plot( x, col = NULL, legend.pos = "topright", legend.bty = "o", legend.cex = 0.8, ... )## S3 method for class 'litfit_list' plot( x, col = NULL, legend.pos = "topright", legend.bty = "o", legend.cex = 0.8, ... )
x |
a |
col |
colours for the curves, recycled; defaults to the colour-blind safe Okabe-Ito palette |
legend.pos |
position of the legend, passed to |
legend.bty |
box type of the legend ( |
legend.cex |
size of the legend text |
... |
additional arguments passed to |
Data points are taken from the first fit; fits in a litfit_list are
normally made to the same data.
x, invisibly
plot_multiple_fits, glance.litfit_list
fits <- fit_litter_all( time = pineneedles$Year, mass.remaining = pineneedles$Mass.remaining, models = c("neg.exp", "weibull", "cont.quality"), iters = 100 ) plot(fits)fits <- fit_litter_all( time = pineneedles$Year, mass.remaining = pineneedles$Mass.remaining, models = c("neg.exp", "weibull", "cont.quality"), iters = 100 ) plot(fits)
Generated predicted values for (new) time points from a litfit model fit
## S3 method for class 'litfit' predict(object,newdata=NULL,...)## S3 method for class 'litfit' predict(object,newdata=NULL,...)
object |
litfit object |
newdata |
optional vector of new Time points at which to predict mass remaining. If not specified, Time points from the original fit are used. |
... |
further arguments passed to or from other methods. |
to do
predicted values from a litfit object
Will Cornwell
James Weedon
fit <- fit_litter( time = c(0, 1, 2, 3, 4, 5, 6), mass.remaining = c(1, 0.9, 1.01, 0.4, 0.6, 0.2, 0.01), "neg.exp", iters = 250 ) predict(fit, newdata = 1:10)fit <- fit_litter( time = c(0, 1, 2, 3, 4, 5, 6), mass.remaining = c(1, 0.9, 1.01, 0.4, 0.6, 0.2, 0.01), "neg.exp", iters = 250 ) predict(fit, newdata = 1:10)
Estimate Steady State Biomass
steady_state(x = NULL, pars = NULL, model = NULL)steady_state(x = NULL, pars = NULL, model = NULL)
x |
A |
pars |
A numeric vector of parameters for the model. Only needed if |
model |
A character string specifying the decomposition model. Must be one of the following:
"neg.exp", "weibull", "discrete.parallel", "discrete.series", "cont.quality" or "neg.exp.limit".
Only needed if |
Computes the steady state biomass, as a proportion of the annual input, based on a given model fit or parameters.
For neg.exp.limit, a fraction of the litter never decomposes, so
the implied steady state is infinite whenever . Because is bounded just
above zero during fitting, values of are treated as zero and the steady
state is .
A named numeric value representing the estimated steady state biomass from the specified model.
Will Cornwell
fit_litter for generating litfit objects.
# Example with litfit object fit <- fit_litter( time = c(0, 1, 2, 3, 4, 5, 6), mass.remaining = c(1, 0.9, 1.01, 0.4, 0.6, 0.2, 0.01), model = "neg.exp", iters = 250 ) steady_state(fit) # Example with specific model and parameter values steady_state(pars = c(6, 2), model = "weibull")# Example with litfit object fit <- fit_litter( time = c(0, 1, 2, 3, 4, 5, 6), mass.remaining = c(1, 0.9, 1.01, 0.4, 0.6, 0.2, 0.01), model = "neg.exp", iters = 250 ) steady_state(fit) # Example with specific model and parameter values steady_state(pars = c(6, 2), model = "weibull")
Summarise a bootstrap distribution of parameters from a litfit object
## S3 method for class 'litfit_bootstrap' summary(object, probs = c(0.025, 0.5, 0.975), ...)## S3 method for class 'litfit_bootstrap' summary(object, probs = c(0.025, 0.5, 0.975), ...)
object |
a |
probs |
quantiles to report (default gives a 95 percent interval and the median) |
... |
unused |
a matrix with one row per parameter (plus steady state) giving the mean and the requested quantiles of the bootstrap distribution, ignoring failed replicates
fit <- fit_litter( time = pineneedles$Year, mass.remaining = pineneedles$Mass.remaining, model = "neg.exp", iters = 100 ) boot1 <- bootstrap_parameters(fit, nboot = 200) summary(boot1)fit <- fit_litter( time = pineneedles$Year, mass.remaining = pineneedles$Mass.remaining, model = "neg.exp", iters = 100 ) boot1 <- bootstrap_parameters(fit, nboot = 200) summary(boot1)
Returns the bootstrap replicates from bootstrap_parameters in long
format, one row per replicate and parameter (including the implied steady state).
Failed replicates are dropped.
## S3 method for class 'litfit_bootstrap' tidy(x, ...)## S3 method for class 'litfit_bootstrap' tidy(x, ...)
x |
a |
... |
unused |
A data.frame with columns replicate, term and value.
fit <- fit_litter( time = pineneedles$Year, mass.remaining = pineneedles$Mass.remaining, model = "neg.exp", iters = 50, quiet = TRUE ) boot <- bootstrap_parameters(fit, nboot = 50) head(tidy(boot))fit <- fit_litter( time = pineneedles$Year, mass.remaining = pineneedles$Mass.remaining, model = "neg.exp", iters = 50, quiet = TRUE ) boot <- bootstrap_parameters(fit, nboot = 50) head(tidy(boot))
Get estimated time to 0.5 (or an alternate threshold) mass loss from a particular fit to a litter decomposition trajectory
time_to_prop_mass_remaining(x,threshold.mass=0.5)time_to_prop_mass_remaining(x,threshold.mass=0.5)
x |
a litfit object |
threshold.mass |
mass loss threshold in proportion, default is 0.5 |
this function finds the time to a specified mass loss percentage
numeric value that represents time to a specified mass loss percentage
Will Cornwell
fit <- fit_litter( time = pineneedles$Year, mass.remaining = pineneedles$Mass.remaining, model = "neg.exp", iters = 1000 ) time_to_prop_mass_remaining(fit, threshold.mass = 0.5)fit <- fit_litter( time = pineneedles$Year, mass.remaining = pineneedles$Mass.remaining, model = "neg.exp", iters = 1000 ) time_to_prop_mass_remaining(fit, threshold.mass = 0.5)