Learn R Programming

litterfitter

R package for fitting and testing alternative models for single cohort litter decomposition data

Installation

  #install.packages("remotes")
  remotes::install_github("cornwell-lab-unsw/litterfitter")
  
library(litterfitter)

Getting started

At the moment there is one key function which is fit_litter which can fit 6 different types of decomposition trajectories. Note that the fitted object is a 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="weibull",
                  iters=500)

class(fit)

You can visually compare the fits of different non-linear equations with the plot_multiple_fits function:

plot_multiple_fits(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=c("neg.exp","weibull"),
                   iters=500)

Calling plot on a litfit object will show you the data, the curve fit, and even the equation, with the estimated coefficients:

   plot(fit)

The summary of a litfit object will show you some of the summary statistics for the fit.

#> Summary of litFit object
#> Model type: weibull 
#> Number of observations:  7 
#> Parameter fits: 4.19 
#> Parameter fits: 2.47 
#> Time to 50% mass loss: 3.61 
#> Implied steady state litter mass: 3.71 in units of yearly input 
#> AIC:  -3.8883 
#> AICc:  -0.8883 
#> BIC:  -3.9965

From the litfit object you can then see the uncertainty in the parameter estimate by bootstrapping

Copy Link

Version

Install

install.packages('litterfitter')

Monthly Downloads

185

Version

0.1.4

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Will Cornwell

Last Published

August 21st, 2025

Functions in litterfitter (0.1.4)

predict_from_fit

Predict Using a Specific Model Function
litterfitter

litterfitter: methods for fitting curves to litter decomposition trajectories
plot.litfit_bootstrap

Plot the bootstrap distribution for a parameter from a litfit object
predict.litfit

Predict method for litfit objects
plot.litfit

Plot Decomposition Trajectory and Curve Fit
fit_litter

Fit different models to single cohort decomposition data
plot_multiple_fits

Plot multiple fits on one graph with model selection results displayed
bootstrap_parameters

Create a bootstrap distribution of a particular coefficient from a model fit
time_to_prop_mass_remaining

Get the predicted time until half mass loss for a litter decomposition trajectory
steady_state

Estimate Steady State Biomass
pineneedles

decomposition trajectory for pine needles
simulate_and_check

Simulate and Check Model Fitting with Litter Data