Gosset_Welch {DanielBiostatistics10th} | R Documentation |
Student's 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,
c1 = 1,
c0 = 1,
v1 = s1^2,
v0 = s0^2,
n1,
n0,
var.equal = FALSE
)
Arguments
s1 , s0 |
(optional) double scalars or vectors,
sample standard deviations |
c1 , c0 |
double scalars or vectors,
multipliers |
v1 , v0 |
double scalars or vectors,
sample variances of the treatment and control sample, respectively.
Default |
n1 , n0 |
integer scalars or vectors,
sample sizes |
var.equal |
logical scalar,
whether to assume |
Details
If v_1=v_0
is assumed, the standard error of two-sample t
-statistic
from William Sealy Gosset (a.k.a., Student) satisfies that
s^2_{\bar\Delta}=s^2_p(1/n_1+1/n_0)
,
with degree-of-freedom \text{df} = 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 standard error of two-sample t
-statistic satisfies that
s^2_{\bar\Delta}=v_1/n_1 + v_0/n_0
, with
degree of freedom (Welch–Satterthwaite equation),
\text{df} = \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')
attr(., 'stderr2')
numeric scalar or vector, standard error squared
s^2_{\bar\Delta}
, included for downstream compute-intensive functions.
References
Student's t
-test by William Sealy Gosset, doi:10.1093/biomet/6.1.1.
Welch–Satterthwaite equation by Bernard Lewis Welch doi:10.1093/biomet/34.1-2.28 and F. E. Satterthwaite doi:10.2307/3002019.
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)