When variance across groups are heterogeneous,
the Student t
distribution with n - 1
df is not the exact distribution.
However, (Welch 1947)
, using methods of moments, was able to find the
best-fitting t
distribution. This distribution has degree of freedom reduced
based on the sample sizes and the variances of the group tests. The present
function returns the rectified degree of freedom
WelchDegreeOfFreedom(dta, cols, groupingcols)
A data frame containing within-subject measures, one participant per line;
A vector indicating the columns containing the measures.
A vector indicating the columns containing the groups.
df the degrees of freedom rectified according to Welch (1947).
Welch BL (1947). “The generalization of student's' problem when several different population variances are involved.” Biometrika, 34(1/2), 28--35. doi:10.1093/biomet/34.1-2.28 .
# creates a small data frames with 4 subject's scores for 5 measures:
dta <- data.frame(cbind(
DV.1 = c(3., 6., 2., 2., 5.),
DV.2 = c(4., 5., 4., 4., 3.),
DV.3 = c(2., 7., 7., 8., 6.),
DV.4 = c(6., 8., 4., 6., 5.),
grp = c(1., 1., 2., 2., 2.)
))
# performs the test (here rectified df = 1.898876)
WelchDegreeOfFreedom(dta, "DV.1","grp")
#> [1] 1.898876