knitr::opts_chunk$set( collapse = TRUE, comment = "#", fig.path = "man/figures/README-", out.width = "100%" )
{nlstimedist} fits a biologically meaningful distribution function to time-sequence data (phenology), estimates parameters to draw the cumulative distribution function and probability density function and calculates standard statistical moments and percentiles.
You can install:
install.packages("nlstimedist")
# install.packages("remotes") remotes::install_github("nathaneastwood/nlstimedist")
Data should be in tidy format. {nlstimedist} provides three example tidy datasets: lobelia
, pupae
and tilia
.
library(nlstimedist) head(tilia)
We first need to calculate the cumulative number of trees as well as the proportions. We do this using the tdData()
function.
tdTilia <- tdData(tilia, x = "Day", y = "Trees") tdTilia
We fit the model to the proportion of the cumulative number of trees (propMax
) in the tdTilia
object using the timedist()
function.
model <- timedist(data = tdTilia, x = "Day", y = "propMax", r = 0.1, c = 0.5, t = 120) model
We can extract the mean, variance, standard deviation, skew, kurtosis and entropy of the model as follows.
model$m$getMoments()
Similarly we can extract the RSS of the model
model$m$rss()
The probability density function (PDF) and the cumulative distribution function (CDF) of the model have their own plotting functions.
tdPdfPlot(model)
tdCdfPlot(model)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.