Description Usage Arguments Value See Also Examples
View source: R/fitDistributionsToCIs.R
Finds the best-fit negative binomial distribution for a given confidence interval; returns the corresponding probability mass, distribution, quantile and sampling functions. The use of this function within the bootComb package is limited: this is a discrete distribution but since users provide confidence intervals, the corresponding parameters will be best approximated by continuous distributions.
1 2 3 4 5 6 7 | getNegBinFromCI(
qLow,
qUpp,
alpha = 0.05,
initPars = c(10, 0.5),
maxiter = 1000
)
|
qLow |
The observed lower quantile. |
qUpp |
The observed upper quantile. |
alpha |
The confidence level; i.e. the desired coverage is 1-alpha. Defaults to 0.05. |
initPars |
A vector of length 2 giving the initial parameter values (size & prob) to start the optimisation; defaults to c(10,0.5). |
maxiter |
Maximum number of iterations for |
A list with 5 elements:
r |
The sampling function. |
d |
The probability mass function. |
p |
The distribution function. |
q |
The quantile function. |
pars |
A vector of length 2 giving the mean and standard deviation for the best-fit negatove binomial distribution ( |
identifyNegBinPars
, optim
, dnbinom
1 2 3 4 5 6 7 8 9 | n<-getNegBinFromCI(qLow=1.96,qUpp=19.12)
print(n$pars) # the fitted parameter values (size & prob)
n$r(10) # 10 random values from the fitted negative binomial distribution
n$d(8) # the probability mass at x=8 for the negative binomial distribution
n$p(12) # the cumulative probability at x=12 for the fitted negative binomial distribution
n$q(c(0.25,0.5,0.75)) # the 25th, 50th (median) and 75th percentiles of the fitted distribution
x<-0:30
y<-n$d(x)
barplot(height=y,names.arg=x,xlab="",ylab="probability mass") # bar plot of the fitted neg. bin. pmf
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.