Type: | Package |
Title: | Confidence Interval Estimation via CDF Inversion |
Version: | 0.1.0 |
Description: | Estimation of one- and two-sided confidence intervals via the numerical inversion of the cumulative distribution function of a statistic's sampling distribution. For more details, see section 9.2.3 of Casella and Berger (2002) <ISBN:0534243126>. |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
VignetteBuilder: | knitr, extraDistr |
Suggests: | knitr, rmarkdown, extraDistr |
NeedsCompilation: | no |
Packaged: | 2025-04-10 15:21:16 UTC; peterfreeman |
Author: | Peter E. Freeman [aut, cre] |
Maintainer: | Peter E. Freeman <pfreeman@cmu.edu> |
Repository: | CRAN |
Date/Publication: | 2025-04-15 19:20:05 UTC |
Computation of confidence intervals via CDF inversion
Description
cdfinv() returns one- or two-sided confidence interval estimates.
Usage
cdfinv(
DISTR,
PARAM,
STAT,
lpb = -10000,
upb = 10000,
bound = "two-sided",
alpha = 0.05,
tolb = 1e-06,
tol = 1e-06,
...
)
Arguments
DISTR |
name of sampling distribution in R |
PARAM |
name of distribution parameter for which we are computing an interval estimate |
STAT |
observed value of the chosen statistic |
lpb |
lower bound of search interval |
upb |
upper bound of search interval |
bound |
one of "two-sided", "lower", or "upper" |
alpha |
the confidence coefficient is 1 - alpha |
tolb |
search interval bound offset value |
tol |
convergence tolerance for uniroot function |
... |
additional arguments for DISTR's cdf function |
Value
A list with interval bounds and associated cdf values.
DISTR - The distribution name (as given in R)
PARAM - The parameter name (as given in R)
STAT - The observed statistic value
bound - The interval bound(s)
q - The cdf quantile(s) associated with the interval bound(s)
Author(s)
Peter E. Freeman, pfreeman@cmu.edu
Examples
cdfinv("norm","mean",3.45,sd=2) ## returns -0.4699279 and 7.3699277
cdfinv("gamma","rate",12.25,lpb=0,bound="upper",shape=10) ## returns 1.282058
cdfinv("nbinom","prob",22,lpb=0,upb=1,bound="lower",size=10) ## returns 0.1803843
Computation of confidence intervals via simulations and CDF inversion
Description
cdfinv.sim() returns one- or two-sided confidence interval estimates.
Usage
cdfinv.sim(
DISTR,
PARAM,
STAT,
lpb = -10000,
upb = 10000,
bound = "two-sided",
alpha = 0.05,
tolb = 1e-06,
tol = 1e-06,
seed = 1,
numsim = 1e+05,
nsamp = 1,
stat.func = mean,
...
)
Arguments
DISTR |
name of distribution (in R) from which each datum is sampled |
PARAM |
name of distribution parameter for which we are computing an interval estimate |
STAT |
observed value of the chosen statistic |
lpb |
lower bound of search interval |
upb |
upper bound of search interval |
bound |
one of "two-sided", "lower", or "upper" |
alpha |
the confidence coefficient is 1 - alpha |
tolb |
search interval bound offset value |
tol |
convergence tolerance for uniroot function |
seed |
random number generator seed |
numsim |
number of simulated datasets |
nsamp |
sample size for each simulated dataset |
stat.func |
pointer to function computing the statistic for each dataset |
... |
additional arguments for DISTR's cdf function |
Value
A list with interval bounds and associated cdf values.
DISTR - The distribution name (as given in R)
PARAM - The parameter name (as given in R)
STAT - The observed statistic value
bound - The interval bound(s)
q - The cdf quantile(s) associated with the interval bound(s)
Author(s)
Peter E. Freeman, pfreeman@cmu.edu
Plotting of confidence intervals derived via CDF inversion
Description
ci_plot() creates a plot showing the cumulative distribution function(s) for the sampling distribution(s) of the chosen statistic, evaluated at the interval bound(s). The horizontal dashed line(s) show(s) the assumed quantile(s) (e.g., 0.95 for a 95% lower-bound), while the vertical dashed line shows the statistic value.
Usage
ci_plot(cdfinv.out, ...)
Arguments
cdfinv.out |
output list from cdfinv() |
... |
those additional arguments that were passed to cdfinv() |
Value
None
Author(s)
Peter E. Freeman, pfreeman@cmu.edu
Examples
ci_plot(cdfinv("norm","mean",2.5,sd=3),sd=3)
Cumulative distribution function for t distribution
Description
Computes the quantile of the chi-square distribution for n-1 degrees of freedom corresponding to the input value of the sample variance.
Usage
pnormvar(q, sigma2, n)
Arguments
q |
coordinate at which the cdf is to be evaluated (named in accordance with R standards) |
sigma2 |
the assumed normal variance |
n |
the sample size (pass this as an extra argument to cdfinv()) |
Details
Do not call pnormvar() directly. Pass DISTR="normvar" to cdfinv() when computing intervals for the normal variance. The parameter name to be passed to cdfinv() is sigma2. The additional argument n (sample size) is to be passed to cdfinv().
Value
The quantile of the chi-square distribution for n-1 degrees of freedom corresponding to the input value of the sample variance.
Author(s)
Peter E. Freeman, pfreeman@cmu.edu
Examples
cdfinv("normvar","sigma2",14.35,lpb=0,n=22) ## returns 8.493787 29.305942
Cumulative distribution function for t distribution
Description
Computes the quantile of the t distribution for n-1 degrees of freedom corresponding to the input value of the sample mean.
Usage
ptmean(q, mean, s2, n)
Arguments
q |
coordinate at which the cdf is to be evaluated (named in accordance with R standards) |
mean |
the assumed normal mean |
s2 |
the observed sample variance (pass this as an extra argument to cdfinv()) |
n |
the sample size (pass this as an extra argument to cdfinv()) |
Details
Do not call ptmean() directly. Pass DISTR="tmean" to cdfinv() when computing intervals for the normal mean when the variance is unknown. The parameter name to be passed to cdfinv() is mean. The additional arguments s2 (sample variance) and n (sample size) are to be passed to cdfinv().
Value
The quantile of the t distribution for n-1 degrees of freedom corresponding to the input value of the sample mean.
Author(s)
Peter E. Freeman, pfreeman@cmu.edu
Examples
cdfinv("tmean","mean",14.35,s2=4.5,n=22) ## returns 13.40946 15.29054
Inverse cumulative distribution function for chi-square distribution
Description
Computes the value of sample variance corresponding to the input quantile p of the chi-square distribution for n-1 degrees of freedom
Usage
qnormvar(p, sigma2, n)
Arguments
p |
the cdf value (named in accordance with R standards) |
sigma2 |
the assumed normal variance |
n |
the sample size (pass this as an extra argument to cdfinv()) |
Details
Do not call qnormvar() directly. Pass DISTR="normvar" to cdfinv() when computing intervals for the normal variance. The parameter name to be passed to cdfinv() is sigma2. The additional argument n (sample size) is to be passed to cdfinv().
Value
The value of sample variance corresponding to the input quantile p of the chi-square distribution for n-1 degrees of freedom
Author(s)
Peter E. Freeman, pfreeman@cmu.edu
Inverse cumulative distribution function for t distribution
Description
Computes the value of sample mean corresponding to the input quantile p of the t distribution for n-1 degrees of freedom
Usage
qtmean(p, mean, s2, n)
Arguments
p |
value of cdf (named in accordance with R standards) |
mean |
the assumed normal mean |
s2 |
the observed sample variance (pass this as an extra argument to cdfinv()) |
n |
the sample size (pass this as an extra argument to cdfinv()) |
Details
Do not call qtmean() directly. Pass DISTR="tmean" to cdfinv() when computing intervals for the normal mean when the variance is unknown. The parameter name to be passed to cdfinv() is mean. The additional arguments s2 (sample variance) and n (sample size) are to be passed to cdfinv().
Value
The value of sample mean corresponding to the input quantile p of the t distribution for n-1 degrees of freedom
Author(s)
Peter E. Freeman, pfreeman@cmu.edu