ci_p_coverage_plot: Plot for confidence interval p - coverage vs p for fixed n

View source: R/ci_p_coverage.R

ci_p_coverage_plotR Documentation

Plot for confidence interval p - coverage vs p for fixed n

Description

This function plots the coverage for any confidence interval for p.

Usage

ci_p_coverage_plot(
  n,
  conf.level = 0.95,
  intervalType = "wald",
  plot = TRUE,
  seq_p = seq(from = 0.01, to = 0.99, length.out = 50),
  col = "deepskyblue2",
  linecolor = "tomato",
  ...
)

Arguments

n

number of trials.

conf.level

nominal confidence level for the returned confidence interval. By default is 0.95.

intervalType

type of confidence interval, possible choices are listed in ci_p.

plot

logical value to obtain the plot, TRUE by default.

seq_p

sequence for the values of n. By default is seq(from=0.01, to=0.99, length.out=50).

col

color for the coverage curve.

linecolor

color for the line representing the conf.level.

...

further arguments and graphical parameters passed to plot function.

Details

This function was inspired by the binomTestCoveragePlot() function from conf package and Park & Leemis (2019).

Value

A dataframe with Method, n, p and true coverage and the plot.

Author(s)

David Esteban Cartagena Mejía, dcartagena@unal.edu.co

References

Park, H., & Leemis, L. M. (2019). Ensemble confidence intervals for binomial proportions. Statistics in Medicine, 38(18), 3460-3475.

See Also

ci_p.

Examples

ci_p_coverage_plot(n=10,
                   intervalType="wald",
                   conf.level=0.95,
                   ylim=c(0.8, 1), las=1)

ci_p_coverage_plot(n=10,
                   intervalType="clopper_pearson",
                   conf.level=0.95,
                   ylim=c(0.9, 1), las=1)

ci_p_coverage_plot(n=10,
                   intervalType="wilson",
                   conf.level=0.95,
                   ylim=c(0.9, 1), las=1)

ci_p_coverage_plot(n=10,
                   intervalType="jeffreys",
                   conf.level=0.95,
                   ylim=c(0.9, 1), las=1)

ci_p_coverage_plot(n=10,
                   intervalType="agresti_coull",
                   conf.level=0.95,
                   ylim=c(0.9, 1), las=1)

ci_p_coverage_plot(n=10,
                   intervalType="arcsine",
                   conf.level=0.95,
                   ylim=c(0.9, 1), las=1)

fhernanb/stests documentation built on March 29, 2025, 10:36 a.m.