# dCount_conv_bi: Compute count probabilities using convolution In Countr: Flexible Univariate Count Models Based on Renewal Processes

## Description

Compute count probabilities using one of several convolution methods. `dCount_conv_bi` does the computations for the distributions with builtin support in this package.

`dCount_conv_user` does the same using a user defined survival function.

## Usage

 ```1 2 3 4 5 6 7``` ```dCount_conv_bi(x, distPars, dist = c("weibull", "gamma", "gengamma", "burr"), method = c("dePril", "direct", "naive"), nsteps = 100, time = 1, extrap = TRUE, log = FALSE) dCount_conv_user(x, distPars, extrapolPars, survR, method = c("dePril", "direct", "naive"), nsteps = 100, time = 1, extrap = TRUE, log = FALSE) ```

## Arguments

 `x` integer (vector), the desired count values. `distPars` `Rcpp::List` with distribution specific slots, see details. `dist` character name of the built-in distribution, see details. `method` character string, the method to use, see Details. `nsteps` unsiged integer, number of steps used to compute the integral. `time` double, time at wich to compute the probabilities. Set to 1 by default. `extrap` logical, if `TRUE`, Richardson extrapolation will be applied to improve accuracy. `log` logical, if `TRUE` the log-probability will be returned. `extrapolPars` vector of length 2, the extrapolation values. `survR` function, user supplied survival function; should have signature `function(t, distPars)`, where `t` is a positive real number (the time where the survival function is evaluated) and `distPars` is a list of distribution parameters. It should return a double value.

## Details

`dCount_conv_bi` computes count probabilities using one of several convolution methods for the distributions with builtin support in this package.

The following convolution methods are implemented: "dePril", "direct", and "naive".

The builtin distributions currently are Weibull, gamma, generalised gamma and Burr.

## Value

vector of probabilities P(x(i),\ i = 1, ..., n) where n is the length of `x`.

## Examples

 ``` 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``` ```x <- 0:10 lambda <- 2.56 p0 <- dpois(x, lambda) ll <- sum(dpois(x, lambda, TRUE)) err <- 1e-6 ## all-probs convolution approach distPars <- list(scale = lambda, shape = 1) pmat_bi <- dCount_conv_bi(x, distPars, "weibull", "direct", nsteps = 200) ## user pwei pwei_user <- function(tt, distP) { alpha <- exp(-log(distP[["scale"]]) / distP[["shape"]]) pweibull(q = tt, scale = alpha, shape = distP[["shape"]], lower.tail = FALSE) } pmat_user <- dCount_conv_user(x, distPars, c(1, 2), pwei_user, "direct", nsteps = 200) max((pmat_bi - p0)^2 / p0) max((pmat_user - p0)^2 / p0) ## naive convolution approach pmat_bi <- dCount_conv_bi(x, distPars, "weibull", "naive", nsteps = 200) pmat_user <- dCount_conv_user(x, distPars, c(1, 2), pwei_user, "naive", nsteps = 200) max((pmat_bi- p0)^2 / p0) max((pmat_user- p0)^2 / p0) ## dePril conv approach pmat_bi <- dCount_conv_bi(x, distPars, "weibull", "dePril", nsteps = 200) pmat_user <- dCount_conv_user(x, distPars, c(1, 2), pwei_user, "dePril", nsteps = 200) max((pmat_bi- p0)^2 / p0) max((pmat_user- p0)^2 / p0) ```

Countr documentation built on Nov. 21, 2017, 1:04 a.m.