
RR exact CI, OTSST method.
RRotsst.RdEstimates confidence interval for the risk ratio or prevented fraction, exact method based on the score statistic (inverts one two-sided test).
Usage
RRotsst(
y = NULL,
data = NULL,
formula = NULL,
compare = c("vac", "con"),
alpha = 0.05,
pf = TRUE,
stepstart = 0.1,
iter.max = 36,
converge = 1e-06,
rnd = 3,
trace.it = FALSE,
nuisance.points = 120,
gamma = 1e-06
)Arguments
- y
Data vector c(y1, n1, y2, n2) where y are the positives, n are the total, and group 1 is compared to group 2 (control or reference).
- data
data.frame containing variables of the formula.
- formula
Formula of the form cbind(y, n) ~ x, where y is the number positive, n is the group size, x is a factor with two levels of treatment.
- compare
Text vector stating the factor levels:
compare[1]is the vaccinate group to whichcompare[2](control or reference) is compared.- alpha
Complement of the confidence level.
- pf
Estimate RR or its complement PF?
- stepstart
starting interval for step search
- iter.max
Maximum number of iterations
- converge
Convergence criterion
- rnd
Number of digits for rounding. Affects display only, not estimates.
- trace.it
Verbose tracking of the iterations?
- nuisance.points
number of points over which to evaluate nuisance parameter
- gamma
parameter for Berger-Boos correction (restricts range of nuisance parameter evaluation)
Value
An object of class rr1 with the following fields:
estimate: vector with point and interval estimateestimator: either"PF"or"RR"y:data.framewith "y1", "n1", "y2", "n2" values.rnd: how many digits to round the displayalpha: complement of confidence level
Details
Estimates confidence intervals based on the score statistic that are 'exact' in the sense of accounting for discreteness. The score statistic is used to select tail area tables, and the binomial probability is estimated over the tail area by taking the maximum over the nuisance parameter. Algorithm is a simple step search.
The data may also be a matrix. In that case Y would be entered as
matrix(c(y1, n1 - y1, y2, n2 - y2), 2, 2, byrow = TRUE).
References
Koopman PAR, 1984. Confidence intervals for the ratio of two binomial proportions. Biometrics 40:513-517.
Agresti A, Min Y, 2001. On small-sample confidence intervals for parameters in discrete distribution. Biometrics 57: 963-971.
Berger RL, Boos DD, 1994. P values maximized over a confidence set for the nuisance parameter. Journal of the American Statistical Association 89:214-220.
Examples
# All examples represent the same observation, with data entry by multiple
# options.
y_vector <- c(4, 24, 12, 28)
RRotsst(y_vector, rnd = 3)
#>
#> PF
#> 95% interval estimates
#>
#> PF LL UL
#> 0.6111 0.0148 0.8519
#>
# PF
# 95% interval estimates
# PF LL UL
# 0.6111 0.0148 0.8519
y_matrix <- matrix(c(4, 20, 12, 16), 2, 2, byrow = TRUE)
RRotsst(y_matrix, rnd = 3)
#>
#> PF
#> 95% interval estimates
#>
#> PF LL UL
#> 0.6111 0.0148 0.8519
#>
# PF
# 95% interval estimates
# PF LL UL
# 0.6111 0.0148 0.8519
require(dplyr)
data1 <- data.frame(group = rep(c("treated", "control"), each = 2),
y = c(1, 3, 7, 5),
n = c(12, 12, 14, 14),
cage = rep(paste("cage", 1:2), 2))
data2 <- data1 |>
group_by(group) |>
summarize(sum_y = sum(y),
sum_n = sum(n))
RRotsst(data = data2, formula = cbind(sum_y, sum_n) ~ group,
compare = c("treated", "control"))
#>
#> PF
#> 95% interval estimates
#>
#> PF LL UL
#> 0.6111 0.0148 0.8519
#>
# PF
# 95% interval estimates
#
# PF LL UL
# 0.6111 0.0148 0.8519