Fit biologically meaningful distribution functions to
time-sequence data (phenology), estimate parameters to draw the cumulative
distribution function and probability density function and calculate
standard statistical moments and percentiles. These methods are described in
Steer et al. (2019)
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")
devtools::install_github("nathaneastwood/nlstimedist")
Data should be in tidy format. nlstimedist provides three example tidy datasets: lobelia, pupae and tilia.
head(tilia)#> 1 94 0#> 2 95 0#> 3 96 1#> 4 103 1#> 5 104 0#> 6 105 3
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#> # A tibble: 26 × 4#> Day Trees cumN propMax#> <int> <dbl> <dbl> <dbl>#> 1 96 1 1 0.01538462#> 2 103 1 2 0.03076923#> 3 105 3 5 0.07692308#> 4 107 1 6 0.09230769#> 5 110 4 10 0.15384615#> 6 111 7 17 0.26153846#> 7 112 3 20 0.30769231#> 8 114 1 21 0.32307692#> 9 115 3 24 0.36923077#> 10 116 6 30 0.46153846#> # ... with 16 more rows
We fit the model to the proportion of the cumulative number of trees (propMax) in the tdTilia data using the timedist function.
model <- timedist(data = tdTilia, x = "Day", y = "propMax", r = 0.1, c = 0.5, t = 120)model#> Nonlinear regression model#> model: propMax ~ 1 - (1 - (r/(1 + exp(-c * (Day - t)))))^Day#> data: data#> r c t#> 0.02721 0.17126 124.84320#> residual sum-of-squares: 0.01806#>#> Number of iterations to convergence: 10#> Achieved convergence tolerance: 1.49e-08
We can extract the mean, variance, standard deviation, skew, kurtosis and entropy of the model as follows.
model$m$getMoments()#> mean variance sd skew kurtosis entropy#> 1 118.0325 180.7509 13.44436 4.324762 46.82073 5.36145
Similarly we can extract the RSS of the model
model$m$rss()#> [1] 0.9930469
The pdf and cdf of the model have their own plotting functions.
tdPdfPlot(model)

tdCdfPlot(model)

Franco, M. (2012). The time-course of biological phenomenon - illustrated with the London Marathon. Unpublished manuscript. Plymouth University.
NEWS.md file to track changes to the package.