Learn R Programming

EpiNow2 (version 1.1.0)

dist_fit: Fit an Integer Adjusted Exponential, Gamma or Lognormal distributions

Description

Fit an Integer Adjusted Exponential, Gamma or Lognormal distributions

Usage

dist_fit(
  values = NULL,
  samples = NULL,
  cores = 1,
  chains = 2,
  dist = "exp",
  verbose = FALSE
)

Arguments

values

Numeric vector of values

samples

Numeric, number of samples to take

cores

Numeric, defaults to 1. Number of CPU cores to use (no effect if greater than the number of chains).

chains

Numeric, defaults to 2. Number of MCMC chains to use. More is better with the minimum being two.

dist

Character string, which distribution to fit. Defaults to exponential ("exp") but gamma ("gamma") and lognormal ("lognorma") are also supported.

verbose

Logical, defaults to FALSE. Should verbose progress messages be printed.

Value

A stan fit of an interval censored distribution

Examples

Run this code
# NOT RUN {
## Integer adjusted exponential model
dist_fit(rexp(1:100, 2), samples = 1000, dist = "exp", 
         cores = ifelse(interactive(), 4, 1), verbose = TRUE)


## Integer adjusted gamma model
dist_fit(rgamma(1:100, 5, 5), samples = 1000, dist = "gamma", 
         cores = ifelse(interactive(), 4, 1), verbose = TRUE)

## Integer adjusted lognormal model
dist_fit(rlnorm(1:100, log(5), 0.2), samples = 1000, dist = "lognormal",
         cores = ifelse(interactive(), 4, 1), verbose = TRUE)

# }

Run the code above in your browser using DataLab