ttest.TFM | R Documentation |
This function performs a simple t-test for each variable in the dataset of a truncated factor model and calculates the False Discovery Rate (FDR) and power.
ttest.TFM(X, p, alpha = 0.05)
X |
A matrix or data frame of simulated or observed data from a truncated factor model. |
p |
The number of variables (columns) in the dataset. |
alpha |
The significance level for the t-test. |
A list containing:
FDR |
The False Discovery Rate calculated from the rejected hypotheses. |
Power |
The power of the test, representing the proportion of true positives among the non-zero hypotheses. |
pValues |
A numeric vector of p-values obtained from the t-tests for each variable. |
RejectedHypotheses |
A logical vector indicating which hypotheses were rejected based on the specified significance level. |
library(MASS)
library(mvtnorm)
set.seed(100)
p <- 400
n <- 120
K <- 5
true_non_zero <- 100
B <- matrix(rnorm(p * K), nrow = p, ncol = K)
FX <- MASS::mvrnorm(n, rep(0, K), diag(K))
U <- mvtnorm::rmvt(n, df = 3, sigma = diag(p))
mu <- c(rep(1, true_non_zero), rep(0, p - true_non_zero))
X <- rep(1, n) %*% t(mu) + FX %*% t(B) + U # The observed data
results <- ttest.TFM(X, p, alpha = 0.05)
print(results)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.