I am studying hypothesis testing.
When performing a one sample t test, we assume a t distribution for the sample mean estimates of the true mean.
When conducting a two independent sample test, it seems that we also assume that the estimates of the difference of the means follow a t distribution.
I used the following code to simulated data, which yields the same parameters and results as the R base t.test implementation.
Am I correct? On what grounds do we assume this?
>expected_diff <- 0
>mean_diff <- mean(a) - mean(b) #mean difference
>df_pool <- length(a) + length(b) - 2 # degrees of freedom
>se_pool <- sqrt(((length(a) - 1) * sd_a^2 + (length(b) - 1) * sd_b^2)/
df_pool) # pooled std. error
>t <- (mean_diff - expected_diff)/ (se_pool * sqrt(1/length(a) + 1/length(b))) # t-statistic
> result <- c(mean_diff, se_pool, t, p, mean(a), mean(b))
> names(result) <- c("Difference of means", "Std Error", "t", "p-value","Mean A","Mean B")
> result
Difference of means Std Error t
1.533321e+00 2.808271e-01 4.728513e+01
p-value Mean A Mean B
1.532661e-140 4.352244e+01 4.198912e+01
> t.test(a,b,var.equal = T)
Two Sample t-test / data: a and b
t = 47.285, df = 298, p-value < 2.2e-16
Alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval: 1.469506 1.597136
Sample estimates:
mean of x mean of y
43.52244 41.98912
The topic in this forum does not address this question: What is the distribution of the difference of two-t-distributions