| 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  | 
| ... | 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
 | 
| 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  | 
| 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  | 
| 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: 
 https://en.wikipedia.org/wiki/Binomial_proportion_confidence_interval#Agresti-Coull_Interval. 
 | 
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
- Newcombe, R. G. (1998). "Two-sided confidence intervals for the single proportion: comparison of seven methods". Statistics in Medicine. 17 (8): 857–872. doi:10.1002/(SICI)1097-0258(19980430)17:8<857::AID-SIM777>3.0.CO;2-E. PMID 9595616. 
- Hezhi Lu, Hua Jin, A new prediction interval for binomial random variable based on inferential models, Journal of Statistical Planning and Inference, Volume 205, 2020, Pages 156-174, ISSN 0378-3758, https://doi.org/10.1016/j.jspi.2019.07.001. 
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)