Gosset_Welch {DanielBiostatistics10th}R Documentation

Degree of Freedom and Standard Error of Two-Sample t-statistic, by Student and Welch–Satterthwaite Equation

Description

To determine the degree of freedom, as well as the standard error, of two-sample t-statistic, with or without the equal-variance assumption.

Usage

Gosset_Welch(s1, s0, v1 = s1^2, v0 = s0^2, n1, n0, var.equal = FALSE)

Arguments

s1, s0

(optional) double scalars or vectors, sample standard deviations s_1 and s_0 of the treatment and control sample, respectively

v1, v0

double scalars or vectors, sample variances of the treatment and control sample, respectively. Default v_1=s_1^2, v_0=s_0^2.

n1, n0

integer scalars or vectors, sample sizes n_1 and n_0 of the treatment and control sample, respectively

var.equal

logical scalar, whether to assume v_1=v_0, default FALSE, see t.test.default.

Details

If v_1=v_0 is assumed, the two-sample t-statistic from William Sealy Gosset (a.k.a., Student) has standard error s_{\bar\Delta}=s_p\sqrt{1/n_1+1/n_0} with degree-of-freedom n_1+n_0-2, where s_p is the pooled standard deviation,

s^2_p=\dfrac{(n_1-1)v_1+(n_0-1)v_0}{n_1+n_0-2}

If v_1\neq v_0, the two-sample t-statistic has standard error s_{\bar\Delta}=\sqrt{v_1/n_1 + v_0/n_0} with degree of freedom based on Welch–Satterthwaite equation,

\dfrac{\left(\dfrac{v_1}{n_1}+\dfrac{v_0}{n_0}\right)^2}{\dfrac{(v_1/n_1)^2}{n_1-1}+\dfrac{(v_0/n_0)^2}{n_0-1}}

Value

Function Gosset_Welch returns a numeric scalar or vector of the degree of freedom, with attributes,

attr(., 'stderr')

numeric, standard error s_{\bar\Delta}

attr(., 'stderr2')

numeric, s^2_{\bar\Delta}, variance of \bar\Delta

References

Student's t-test by William Sealy Gosset, doi:10.1093/biomet/6.1.1.

Welch–Satterthwaite equation by Bernard Lewis Welch and F. E. Satterthwaite, doi:10.2307/3002019 and doi:10.1093/biomet/34.1-2.28.

Examples

x = rnorm(32L, sd = 1.6); y = rnorm(57L, sd = 2.1)
vx = var(x); vy = var(y); nx = length(x); ny = length(y)
t.test(x, y, var.equal = FALSE)[c('parameter', 'stderr')]
Gosset_Welch(v1 = vx, v0 = vy, n1 = nx, n0 = ny, var.equal = FALSE)
t.test(x, y, var.equal = TRUE)[c('parameter', 'stderr')]
Gosset_Welch(v1 = vx, v0 = vy, n1 = nx, n0 = ny, var.equal = TRUE)

[Package DanielBiostatistics10th version 0.2.4 Index]