poolVar(var, df=n-1, multiplier=1/n, n)
var
are assumed to follow scaled chi-square distributions.
A scaled chi-square approximation is found for the distribution of sum(multiplier * var)
by equating first and second moments.
On output the sum to be approximated is equal to multiplier * var
which follows approximately a scaled chisquare distribution on df
degrees of freedom.
The approximation was proposed by Satterthwaite (1946).
If there are only two groups and the degrees of freedom are one less than the sample sizes then this gives the denominator of Welch's t-test for unequal variances.# Welch's t-test with unequal variances
x <- rnorm(10,mean=1,sd=2)
y <- rnorm(20,mean=2,sd=1)
s2 <- c(var(x),var(y))
n <- c(10,20)
out <- poolVar(var=s2,n=n)
tstat <- (mean(x)-mean(y)) / sqrt(out$var*out$multiplier)
pvalue <- 2*pt(-abs(tstat),df=out$df)
# Equivalent to t.test(x,y)
Run the code above in your browser using DataLab