conversionHelpers: Convert between estimates, z-values, p-values, and confidence...

ci2seR Documentation

Convert between estimates, z-values, p-values, and confidence intervals

Description

Convert between estimates, z-values, p-values, and confidence intervals

Usage

ci2se(lower, upper, conf.level = 0.95, ratio = FALSE)

ci2estimate(lower, upper, ratio = FALSE, antilog = FALSE)

ci2z(lower, upper, conf.level = 0.95, ratio = FALSE)

ci2p(
  lower,
  upper,
  conf.level = 0.95,
  ratio = FALSE,
  alternative = c("two.sided", "one.sided", "less", "greater")
)

z2p(z, alternative = c("two.sided", "one.sided", "less", "greater"))

p2z(p, alternative = c("two.sided", "one.sided", "less", "greater"))

Arguments

lower

Numeric vector of lower confidence interval bounds.

upper

Numeric vector of upper confidence interval bounds.

conf.level

The confidence level of the confidence intervals. Default is 0.95.

ratio

Indicates whether the confidence interval is for a ratio, e.g. an odds ratio, relative risk or hazard ratio. If TRUE, the standard error of the log ratio is computed. Defaults to FALSE.

antilog

Indicates whether the estimate is reported on the ratio scale. Only applies if ratio = TRUE. Defaults to FALSE.

alternative

Direction of the alternative of the p-value. Either "two.sided" (default), "one.sided", "less", or "greater". If "one.sided" or "two.sided" is specified, the z-value is assumed to be positive.

z

Numeric vector of z-values.

p

Numeric vector of p-values.

Details

z2p is the vectorized version of the internal function .z2p_. Vectorize is used to vectorize the function.

p2z is the vectorized version of the internal function .p2z_. Vectorize is used to vectorize the function.

Value

ci2se returns a numeric vector of standard errors.

ci2estimate returns a numeric vector of parameter estimates.

ci2z returns a numeric vector of z-values.

ci2p returns a numeric vector of p-values.

z2p returns a numeric vector of p-values.

p2z returns a numeric vector of z-values.

Examples

ci2se(lower = 1, upper = 3)
ci2se(lower = 1, upper = 3, ratio = TRUE)
ci2se(lower = 1, upper = 3, conf.level = 0.9)

ci2estimate(lower = 1, upper = 3)
ci2estimate(lower = 1, upper = 3, ratio = TRUE)
ci2estimate(lower = 1, upper = 3, ratio = TRUE, antilog = TRUE)

ci2z(lower = 1, upper = 3)
ci2z(lower = 1, upper = 3, ratio = TRUE)
ci2z(lower = 1, upper = 3, conf.level = 0.9)

ci2p(lower = 1, upper = 3)
ci2p(lower = 1, upper = 3, alternative = "one.sided")

z2p(z = c(1, 2, 5))
z2p(z = c(1, 2, 5), alternative = "less")
z2p(z = c(1, 2, 5), alternative = "greater")
z <- seq(-3, 3, by = 0.01)
plot(z, z2p(z), type = "l", xlab = "z", ylab = "p", ylim = c(0, 1))
lines(z, z2p(z, alternative = "greater"), lty = 2)
legend("topright", c("two-sided", "greater"), lty = c(1, 2), bty = "n")

p2z(p = c(0.005, 0.01, 0.05))
p2z(p = c(0.005, 0.01, 0.05), alternative = "greater")
p2z(p = c(0.005, 0.01, 0.05), alternative = "less")
p <- seq(0.001, 0.05, 0.0001)
plot(p, p2z(p), type = "l", ylim = c(0, 3.5), ylab = "z")
lines(p, p2z(p, alternative = "greater"), lty = 2)
legend("bottomleft", c("two-sided", "greater"), lty = c(1, 2), bty = "n")

ReplicationSuccess documentation built on April 3, 2023, 5:11 p.m.