-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
92 lines (67 loc) · 2.57 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
---
output:
md_document:
variant: markdown_github
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# {nlstimedist}
[![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![Travis-CI Build Status](https://travis-ci.org/nathaneastwood/nlstimedist.svg?branch=master)](https://travis-ci.org/nathaneastwood/nlstimedist)
[![](http://www.r-pkg.org/badges/version/nlstimedist)](https://www.r-pkg.org/pkg/nlstimedist)
![CRAN downloads](https://cranlogs.r-pkg.org/badges/nlstimedist)
[![codecov](https://codecov.io/gh/nathaneastwood/nlstimedist/branch/master/graph/badge.svg)](https://codecov.io/gh/nathaneastwood/nlstimedist)
{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.
## Installation
You can install:
* the latest released version from CRAN with
```{r cran, eval = FALSE}
install.packages("nlstimedist")
```
* the latest development version from GitHub with
```{r gh, eval = FALSE}
# install.packages("remotes")
remotes::install_github("nathaneastwood/nlstimedist")
```
## Usage
### Preparing the data
Data should be in tidy format. {nlstimedist} provides three example tidy datasets: `lobelia`, `pupae` and `tilia`.
```{r data}
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.
```{r tidy}
tdTilia <- tdData(tilia, x = "Day", y = "Trees")
tdTilia
```
### Fitting the model
We fit the model to the proportion of the cumulative number of trees (`propMax`) in the `tdTilia` object using the `timedist()` function.
```{r model}
model <- timedist(data = tdTilia, x = "Day", y = "propMax", r = 0.1, c = 0.5, t = 120)
model
```
### Extracting the moments
We can extract the mean, variance, standard deviation, skew, kurtosis and entropy of the model as follows.
```{r moments}
model$m$getMoments()
```
### Extracting the RSS
Similarly we can extract the RSS of the model
```{r rss}
model$m$rss()
```
### Plotting the PDF and CDF
The probability density function (PDF) and the cumulative distribution function (CDF) of the model have their own plotting functions.
```{r pdfPlot}
tdPdfPlot(model)
```
```{r cdfPlot}
tdCdfPlot(model)
```