Skip to content

DF_Welch

Description

DF_Welch returns an estimate of the degrees of freedom for the test statistic in Welch’s two-sample t-test or, more generally, for the standard error of the sum or difference of independent normally-distributed variables.

The estimate is calculated with the Welch-Satterthwaite equation, which gives the relationship between the standard error of d=a±bd = a \pm b with the degrees of freedom of the standard deviations sas_a and sbs_b:

sd4νd≈sa4νa+sb4νb \frac{s_d^4}{\nu_d} \approx \frac{s_a^4}{\nu_a} + \frac{s_b^4}{\nu_b}

where ν\nu refers to the degrees of freedom.

Syntax

DF_Welch(se_1, df_1, se_2, df_2) where the standard errors se and the degrees of freedom df refer to those values in the Welch-Satterthwaite equation given earlier.

The function returns a single number that is usually not an integer. Some statistical routines require degrees of freedom to be integers and the usual practice is to round down to the nearest integer. Some routines will do this automatically while others will interpolate their output based on the non-integer value νd\nu_d.

Example

A common use case for DF_Welch is when one wishes to report a parametric confidence interval for the difference of two means or trimmed means if we do not want to assume homogeneous variance in the comparison. (This is the CI for Welch’s t-test.) This use-case is shown in the example below: we are comparing the measurement errors of males and females to see if gender is a significant factor determining measurement accuracy for this particular protocol. We are using 20% trimmed means to do this to reduce the effects of outliers. We calculate the difference of means and the std error of that difference, and then use DF_Welch to determine the degrees of freedom of that standard error.

As a sanity check: the value returned by DF_Welch should be between min(df_1,df_2) and df_1 + df_2. The sanity check holds in this instance.

Trimmed means of errors by gender with SEs and DOF; DF_Welch gives 155.9 DOF for their difference, with 95% MOE 0.12

Download: DF_Welch.xlsx

Source Code

DF_Welch = LAMBDA(
    se_1, // std error of the first variable
    df_1, // DOF of the first std error
    se_2, // std error of the second variable
    df_2, // DOF of the second std error
    LET(sd_sqrd, se_1 ^ 2 + se_2 ^ 2, sd_sqrd ^ 2 / (se_1 ^ 4 / df_1 + se_2 ^ 4 / df_2))
);