binomProbs {rxode2}R Documentation

Calculate expected confidence bands with binomial sampling distribution

Description

This is meant to perform in the same way as quantile() so it can be a drop in replacement for code using quantile() but using distributional assumptions.

Usage

binomProbs(x, ...)

## Default S3 method:
binomProbs(
  x,
  probs = c(0.025, 0.05, 0.5, 0.95, 0.975),
  na.rm = FALSE,
  names = TRUE,
  onlyProbs = TRUE,
  n = 0L,
  m = 0L,
  pred = FALSE,
  piMethod = c("lim"),
  M = 5e+05,
  tol = .Machine$double.eps^0.25,
  ciMethod = c("wilson", "wilsonCorrect", "agrestiCoull", "wald", "wc", "ac"),
  ...
)

Arguments

x

numeric vector whose mean and probability based confidence values are wanted, NA and NaN values are not allowed in numeric vectors unless na.rm is TRUE.

...

Arguments passed to default method, allows many different methods to be applied.

probs

numeric vector of probabilities with values in the interval 0 to 1, inclusive. When 0, it represents the maximum observed, when 1, it represents the maximum observed. When 0.5 it represents the expected probability (mean).

na.rm

logical; if true, any NA and NaN's are removed from x before the quantiles are computed.

names

logical; if true, the result has a names attribute.

onlyProbs

logical; if true, only return the probability based confidence interval/prediction interval estimates, otherwise return extra statistics.

n

integer/integerish; this is the n used to calculate the prediction or confidence interval. When n=0 (default) use the number of non-NA observations. When calculating the prediction interval, this represents the number of observations used in the input ("true") distribution.

m

integer. When using the prediction interval this represents the number of samples that will be observed in the future for the prediction interval.

pred

Use a prediction interval instead of a confidence interval. By default this is FALSE.

piMethod

gives the prediction interval method (currently only lim) from Lu 2020

M

number of simulations to run for the LIM PI.

tol

tolerance of root finding in the LIM prediction interval

ciMethod

gives the method for calculating the confidence interval.

Can be:

  • "argestiCoull" or "ac" – Agresti-Coull method. For a 95\ interval, this method does not use the concept of "adding 2 successes and 2 failures," but rather uses the formulas explicitly described in the following link:

https://en.wikipedia.org/wiki/Binomial_proportion_confidence_interval#Agresti-Coull_Interval.

  • "wilson" – Wilson Method

  • "wilsonCorrect" or "wc" – Wilson method with continuity correction

  • "wald" – Wald confidence interval or standard z approximation.

Details

It is used for confidence intervals with rxode2 solved objects using confint(mean="binom")

Value

By default the return has the probabilities as names (if named) with the points where the expected distribution are located given the sampling mean and standard deviation. If onlyProbs=FALSE then it would prepend mean, variance, standard deviation, minimum, maximum and number of non-NA observations.

Author(s)

Matthew L. Fidler

References

Examples


x<- rbinom(7001, p=0.375, size=1)
binomProbs(x)

# you can also use the prediction interval

binomProbs(x, pred=TRUE)


# Can get some extra statistics if you request onlyProbs=FALSE
binomProbs(x, onlyProbs=FALSE)

x[2] <- NA_real_

binomProbs(x, onlyProbs=FALSE)

binomProbs(x, na.rm=TRUE)


[Package rxode2 version 2.1.3 Index]