confIntIndependentProportion: Confidence interval for the risk difference of two...

View source: R/confIntProportion.R

confIntIndependentProportionR Documentation

Confidence interval for the risk difference of two independent samples

Description

Compute confidence interval for the risk difference of two independent samples based on individual Wilson intervals using Newcombe's method.

Usage

confIntIndependentProportion(x, n, conf.level = 0.95)

Arguments

x

Vector with two entries, the successes in the two groups.

n

Vector with two entries, the number of trials.

conf.level

Confidence level for confidence interval.

Value

A list with the entries:

p1

Estimated proportion in first sample.

p2

Estimated proportion in second sample.

d

Estimated difference p_1 - p_2 of proportions.

newcombeCI

Confidence interval for the difference of independent proportions, computed according to Newcombe's method.

waldCI

Wald confidence interval for the difference of independent proportions.

Author(s)

Leonhard Held

References

The Newcombe interval is introduced in

Newcombe, R.G. (1998). Interval estimation for the difference between independent proportions: Comparison of eleven methods. Stat. Med., 17, 873–890.

A worked out example can be found in

Altman, D.G., Machin, D., Bryant, T.N., Gardner, M.J. (2000). Statistics with confidence (p. 49). University Press Belfast.

See Also

confIntPairedProportion, confIntProportion, fisher.test, exact2x2

Examples


# Example from Significance (2010), 7(4), p. 146, "Untimely ripped ?"
n <- c(1515, 108000)
x <- c(0, 100)
confIntIndependentProportion(x = x, n = n)

# Fisher p-value
tab <- matrix(data = c(x, n - x), nrow = 2, ncol = 2)
fisher <- fisher.test(x = tab)
fisher$p.value

# exact tests
if(require("exact2x2")){
    exact2x2(x = tab, tsmethod = "minlike")$p.value
    exact2x2(x = tab, tsmethod = "central")$p.value
    exact2x2(x = tab, tsmethod = "blaker")$p.value
}


felix-hof/biostatUZH documentation built on Sept. 27, 2024, 1:48 p.m.