vcovpower: Power calculation for model coefficients

Description Usage Arguments Value Examples

Description

Calculates the power for model coefficients based on a supplied alpha error, beta error, covariance matrix, and desired resolution for each coefficient.

Usage

1
vcovpower(vcovmat, detectdiff, test_alpha = 0.05, test_beta = 0.2)

Arguments

vcovmat

Covariance matrix to use for power calculations. Alternatively, this can be a vector taken from the diagonal of a covariance matrix.

detectdiff

Vector of detectable difference to use for power calculations. This should be equal to the absolute difference in each coefficient that the user would like to detect.

test_alpha

Vector of alpha errors to use for each power calculation. Defaults to 0.05.

test_beta

Vector of beta errors to use for each power calculation. Defaults to 0.20.

Value

Data frame with estimated minimum sample size required to estimate each parameter as well as the input values provided by the user for each calculation.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (vcovmat, detectdiff, test_alpha = 0.05, test_beta = 0.2)
{
    if (length(test_alpha) == 1) {
        test_alpha <- rep(test_alpha, ncol(CurrentMatrix))
    }
    if (length(test_beta) == 1) {
        test_beta <- rep(test_beta, ncol(CurrentMatrix))
    }
    z_one_minus_alpha <- qnorm(1 - test_alpha)
    z_one_minus_beta <- qnorm(1 - test_beta)
    minsamplesize <- ((z_one_minus_beta + z_one_minus_alpha) *
        sqrt(diag(vcovmat))/abs(detectdiff))^2
    output <- data.frame(rownames(vcovmat), detectdiff, minsamplesize,
        test_alpha, test_beta)
    colnames(output) <- c("Effect Name", "Difference to Detect",
        "Minimum Sample Size", "Alpha", "Beta")
    return(output)
  }

taalbrecht/MultiEqOptimizer documentation built on May 31, 2019, 12:51 a.m.