Skip to content

ttestPower

Description

ttestPower performs a post-hoc power analysis of a one-sample or two-sample t-test. The function returns the statistical power that describes the probability of detecting a user-specified effect size.

Syntax

ttestPower(s_d, df, ES, [alpha = 0.05]) where

  • s_d is the standard deviation of the test statistic
  • df is the degrees of freedom of the std deviation
  • ES is the effect size that the user wants to be able to detect
  • alpha is the significance level of the hypothesis test

The function returns the probability that the procedure would detect the desired effect size.

Example

We will use the same data as with the ttestES documentation: 12 students measured the hydrogen peroxide levels in an OTC formulation that nominally contains 30 g/L of active ingredient. We want to be able to detect a deviation of 0.5 g/L from this amount; what is the probability of this level of deviation from nominal being detected using this measurement and statistical protocol? This function returns the answer (assuming all assumptions are valid): we have only a 30% chance of detecting that deviation.

The same H2O2 data; ttestPower gives a 30.3% chance of detecting a 0.5 g/L effect

Download: ttestPower.xlsx

Source Code

ttestPower = LAMBDA(
    s_d, // std deviation of the (non-studentized) test stat
    df, // degrees of freedom of s_d
    ES, // effect size to be detected by the t-test
    [alpha], // desired significance level (default 0.05)
    LET(
        alpha, IF(ISOMITTED(alpha), 0.05, alpha),
        tcrit, T.INV.2T(alpha, df),
        t_ES, ABS(ES) / s_d - tcrit,
        T.DIST(t_ES, df, TRUE)
    )
);