Commits (4)
Package: tvgeom
Title: The Time-Varying (Right-Truncated) Geometric Distribution
Version: 1.0.0
Version: 1.0.1
Authors@R: c(
person(given = "Vincent", family = "Landau", role = c("aut", "cre"),
email = "vincent@csp-inc.org"),
......@@ -9,23 +9,31 @@ Authors@R: c(
person(given = "Conservation Science Partners, Inc.", role = c("cph"),
email = "info@csp-inc.org")
)
Description: R package for the time-varying geometric distribution and related
functions.
Description: Probability mass (d), distribution (p), quantile (q), and random
number generating (r and rt) functions for the time-varying right-truncated
geometric (tvgeom) distribution. Also provided are functions to calculate the first
and second central moments of the distribution. The tvgeom distribution
is similar to the geometric distribution, but the probability
of success is allowed to vary at each time step, and there are a limited
number of trials. This distribution is essentially a Markov chain, and it
is useful for modeling Markov chain systems with a set
number of time steps.
License: MIT + file LICENSE
Copyright: 2019 Conservation Science Partners, Inc.
Encoding: UTF-8
LazyData: true
Depends:
R (>= 3.5.0)
Suggests:
ggthemes,
ggplot2,
dplyr,
tidyr,
purrr,
magrittr,
gridExtra
Imports:
utils,
knitr,
rmarkdown,
magrittr,
gridExtra,
testthat
Roxygen: list(markdown = TRUE)
RoxygenNote: 6.1.1
......
......@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [1.0.1]
- Added depends entry for R and cleaned up imports and suggests
## 1.0.0
- The initial release of the time-varying geometric distribution R package.
- The initial release of the tvgeom R package.
[1.0.1]: https://gitlab.com/actionable-phenology/tvgeom/compare/v1.0.0...v1.0.1
......@@ -4,7 +4,8 @@
#' moment \code{tvgeom_var()} for the time-varying geometric distribution.
#'
#' @param prob vector of the probability of success for each trial/time step.
#'
#' @return \code{tvgeom_mean} returns the moment (the mean), and
#' \code{tvgeom_var} returns the second central moment (the variance).
#' @name tvgeom-moments
#' @examples
#' tvgeom_mean(prob = rep(0.1, 5))
......
......@@ -9,8 +9,10 @@
#' The time-varying geometric distribution describes the number of independent
#' Bernoulli trials needed to obtain one success. The probability of success,
#' \code{prob}, may vary for each trial. It has mass \deqn{p(x) = prob[x] *
#' prod(1 - prob[1:(x-1)])} with support \eqn{x = 1, 2, ..., n}. For \eqn{i} in
#' \eqn{prob, 0 \le i \le 1}.
#' prod(1 - prob[1:(x-1)])} with support \eqn{x = 1, 2, ..., n + 1},
#' where \code{n} equals then length of \code{prob}. For \eqn{i} in
#' \eqn{prob, 0 \le i \le 1}. The \code{n+1} case represents the case that the event did not
#' happen in the first n trials.
#'
#' @param x,q vector of quantiles representing the trial at which the first
#' success occurred.
......@@ -26,6 +28,10 @@
#' @param log,log.p logical; if \code{TRUE}, probabilities, p, are given as
#' \code{log(p)}. Defaults to \code{FALSE}.
#' @param lower.tail logical; if \code{FALSE}, \code{ptvgeom} returns
#' @return dtvgeom gives the probability mass, qtvgeom gives the
#' quantile functions, ptvgeom gives the distribution function, rtvgeom
#' generates random numbers, and rttvgeom gives random numbers from the
#' distribution truncated at bounds provided by the user.
#' \eqn{P(X > x)} instead of \eqn{P(X \le x)}. Defaults to \code{TRUE}.
#' @name tvgeom
#' @examples
......
......@@ -2,7 +2,7 @@
### Description
This R package contains pmf, cdf, quantile, and random number generation functions for the time-varying geometric distribution. The time-varying geometric distribution is derived from the geometric distribution and has a vector of success probabilities as its parameter. Whereas the geometric distribution has a constant probability of success over time and has no upper bound of support, the time-varying geometric distribution has a probability of success that changes over time. Additionally, to accommodate situations in which the event can only occur in $n$ days, after which success can not occur, the time-varying geometric distribution is right-truncated (it has a maximum possible value of the length, *n*, of the probability vector plus 1). When a time-varying geometric distributed variable has value *n+1*, this means the event did not occur in the first *n* time steps. For more detailed information on this package and the time-varying geometric distribution, please see the package vignette.
This R package contains PMF, CDF, quantile, and random number generation functions for the time-varying right-truncated geometric (tvgeom) distribution. The tvgeom distribution is derived from the geometric distribution and has a vector of success probabilities as its parameter. Whereas the geometric distribution has a constant probability of success over time and has no upper bound of support, the tvgeom distribution has a probability of success that changes over time. Additionally, to accommodate situations in which the event can only occur in $n$ days, after which success can not occur, the tvgeom distribution is right-truncated (it has a maximum possible value of the length, *n*, of the probability vector plus 1). When a tvgeom distributed variable has value *n+1*, this means the event did not occur in the first *n* time steps. For more detailed information on this package and the tvgeom distribution, please see the package vignette.
### Example
The following example demonstrates the relationship between the geometric distribution and the time-varying geometric distribution.
......@@ -68,4 +68,4 @@ install.packages("tvgeom")
or to get the latest development version
```
devtools::install_gitlab("actionable-phenology/tvgeom")
```
\ No newline at end of file
```
......@@ -5,12 +5,12 @@ citEntry(entry = "Manual",
author = personList(as.person("Vincent A. Landau"),
as.person("Luke J. Zachmann")),
year = "2019",
note = "R package version X.Y.Z",
note = "R package version 1.0.1",
url = "https://gitlab.com/actionable-phenology/tvgeom/",
textVersion =
paste("Landau, V. A. and L. J. Zachmann (2019).",
"tvgeom: an R package for the time-varying geometric distribution.",
"R package version X.Y.Z.",
"R package version 1.0.1.",
"URL https://gitlab.com/actionable-phenology/tvgeom/.")
)
......@@ -13,6 +13,10 @@ tvgeom_var(prob)
\arguments{
\item{prob}{vector of the probability of success for each trial/time step.}
}
\value{
\code{tvgeom_mean} returns the moment (the mean), and
\code{tvgeom_var} returns the second central moment (the variance).
}
\description{
Functions to calculate first moment \code{tvgeom_mean()} and second central
moment \code{tvgeom_var()} for the time-varying geometric distribution.
......
......@@ -30,8 +30,7 @@ success occurred.}
\item{log, log.p}{logical; if \code{TRUE}, probabilities, p, are given as
\code{log(p)}. Defaults to \code{FALSE}.}
\item{lower.tail}{logical; if \code{FALSE}, \code{ptvgeom} returns
\eqn{P(X > x)} instead of \eqn{P(X \le x)}. Defaults to \code{TRUE}.}
\item{lower.tail}{logical; if \code{FALSE}, \code{ptvgeom} returns}
\item{p}{vector of probabilities at which to evaluate the quantile function.}
......@@ -45,6 +44,13 @@ distribution is not left-truncated.}
for random number generation. Defaults to \code{length(prob)}, in which case
the distribution is not right-truncated.}
}
\value{
dtvgeom gives the probability mass, qtvgeom gives the
quantile functions, ptvgeom gives the distribution function, rtvgeom
generates random numbers, and rttvgeom gives random numbers from the
distribution truncated at bounds provided by the user.
\eqn{P(X > x)} instead of \eqn{P(X \le x)}. Defaults to \code{TRUE}.
}
\description{
The tvgeom package provides two categories of important functions:
probability distribution functions (d, p, q, r) and moments (tvgeom_mean and
......@@ -60,8 +66,10 @@ distribution with parameter \code{prob}.
The time-varying geometric distribution describes the number of independent
Bernoulli trials needed to obtain one success. The probability of success,
\code{prob}, may vary for each trial. It has mass \deqn{p(x) = prob[x] *
prod(1 - prob[1:(x-1)])} with support \eqn{x = 1, 2, ..., n}. For \eqn{i} in
\eqn{prob, 0 \le i \le 1}.
prod(1 - prob[1:(x-1)])} with support \eqn{x = 1, 2, ..., n + 1},
where \code{n} equals then length of \code{prob}. For \eqn{i} in
\eqn{prob, 0 \le i \le 1}. The \code{n+1} case represents the case that the event did not
happen in the first n trials.
}
\section{Package functions}{
......