Title: | Confidence Intervals for Exceedance Probability |
---|---|
Description: | Computes confidence intervals for the exceedance probability of normally distributed estimators. Currently only supports general linear models. Please see Segal (2019) <arXiv:1803.03356> for more information. |
Authors: | Brian D. Segal [aut, cre] |
Maintainer: | Brian D. Segal <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.0.1 |
Built: | 2025-02-12 16:46:09 UTC |
Source: | https://github.com/cranhaven/cranhaven.r-universe.dev |
This function obtains confidence intervals for exceedance probability
exceedProb(cutoff, theta_hat, sd_hat, alpha, d, n, m, interval = c(-100, 100), lower_tail = FALSE)
exceedProb(cutoff, theta_hat, sd_hat, alpha, d, n, m, interval = c(-100, 100), lower_tail = FALSE)
cutoff |
Cutoff values (scalar or vector) |
theta_hat |
Point estimate for the parameter of interest |
sd_hat |
Estimated standard deviation for the parameter of interest (Note: not the standard error) |
alpha |
Significance level |
d |
Number of parameters in the general linear model |
n |
Number of observations in the initial study |
m |
Number of observations in the replication study |
interval |
Interval within which to search for roots |
lower_tail |
If TRUE, reports lower tail probabilities |
ep Exceedance probability with confidence intervals
library(exceedProb) # Sample mean ------------------------------------------------------- n <- 100 x <- rnorm(n = n) theta_hat <- mean(x) sd_hat <- sd(x) cutoff <- seq(from = theta_hat - 0.5, to = theta_hat + 0.5, by = 0.1) exceedProb(cutoff = cutoff, theta_hat = theta_hat, sd_hat = sd_hat, alpha = 0.05, d = 1, n = n, m = n) # Linear regression ------------------------------------------------- n <- 100 beta <- c(1, 2) x <-runif(n = n, min = 0, max = 10) y <- rnorm(n = n, mean = cbind(1, x) %*% beta, sd = 1) j <- 2 fit <- lm(y ~ x) theta_hat <- coef(fit)[j] sd_hat <- sqrt(n * vcov(fit)[j, j]) cutoff <- seq(from = theta_hat - 0.5, to = theta_hat + 0.5, by = 0.1) exceedProb(cutoff = cutoff, theta_hat = theta_hat, sd_hat = sd_hat, alpha = 0.05, d = length(beta), n = n, m = n)
library(exceedProb) # Sample mean ------------------------------------------------------- n <- 100 x <- rnorm(n = n) theta_hat <- mean(x) sd_hat <- sd(x) cutoff <- seq(from = theta_hat - 0.5, to = theta_hat + 0.5, by = 0.1) exceedProb(cutoff = cutoff, theta_hat = theta_hat, sd_hat = sd_hat, alpha = 0.05, d = 1, n = n, m = n) # Linear regression ------------------------------------------------- n <- 100 beta <- c(1, 2) x <-runif(n = n, min = 0, max = 10) y <- rnorm(n = n, mean = cbind(1, x) %*% beta, sd = 1) j <- 2 fit <- lm(y ~ x) theta_hat <- coef(fit)[j] sd_hat <- sqrt(n * vcov(fit)[j, j]) cutoff <- seq(from = theta_hat - 0.5, to = theta_hat + 0.5, by = 0.1) exceedProb(cutoff = cutoff, theta_hat = theta_hat, sd_hat = sd_hat, alpha = 0.05, d = length(beta), n = n, m = n)
This function obtains confidence intervals for the non-centrality parameter of a t-distribution.
getDeltaCI(test_stat, alpha, d, n, interval)
getDeltaCI(test_stat, alpha, d, n, interval)
test_stat |
Test statistics |
alpha |
Significance level |
d |
Number of parameters in general linear model |
n |
Number of observations in initial study |
interval |
Interval within which to search for roots |
ep Exceedance probability with confidence intervals (vector if cutoff is scalar and matrix otherwise)
This function returns the cdf of a noncentral t-distribution. It is more accurate than stats::pt() for large ncp
pnct(x, df, ncp)
pnct(x, df, ncp)
x |
Test statistic |
df |
Degrees of freedom |
ncp |
Noncentrality parameter |
Cumulative probability
This function returns the difference between the lower tail probability of a non-central t-distribution and a confidence level q where the t-distribution has df degrees of freedom and non-centrality parameter delta.
tRoot(delta, test_stat, df, conf_level)
tRoot(delta, test_stat, df, conf_level)
delta |
Non-centrality parameter |
test_stat |
Test statistic at which to evaluate the t-distribution |
df |
Degrees of freedom |
conf_level |
Confidence level (usually alpha/2 or 1-alpha/2) |
dif Difference between t-distribution quantile and confidence level