t - test background:
1. sample from normal populations
normal sample的sample mean也是正态分布,var 是chi-square distribution,这两个variable statistically independent
2.
3. if the population mean is var is and sample mean is
~
One sample test
已知population的sample mean, test sample mean与其是否有明显差异
workflow
我们通常选为0.05
R:t.test(x , mu = population mean , alternative = c("two.sided", "less", "greater") )
Two sample test
检验两个sample的sample mean是否相同
workflow:
R:t.test(x , y , mu = population mean , alternative = c("two.sided", "less", "greater"),, var.equal = TRUE )
If we do not assume equal variance, var.equal = FALSE which is a Welch t-test. But this is not a propor t-statistic because of independent of the numerator.
Paired sample t-test
测试两个一一对应的样本平均值的差距
workflow:
Confidence interval
is false alarm rate
c = qt(1- )/2, degree of freedom)
t.test(x, mu = population mean, conf.level = 0.99)
we reject H0 if outside the bounds
One-sided confidence intervals
用R的时候改一下alternative
The observed signficance level (or p-value) is the value of for which the observed data is "right on the edge". The non-coverage probability (i.e. 1 - confidence interval) for which is on the boundary of the confidence interval. R example: t.test(x, mu = 375, alt = "less" , conf.level = 1-0.1589)
Rejection regions
Critical value decision rule
Rejection region for test statistics
Rejection region for sample mean & sample scale
和 d 拿第一个图推导即可
power increase as n increase, false alarm rate越小,the number of se to reject H0越少
R大法 pwr package
pwr.t.test() t-tests (one sample, 2 sample, paired)
pwr.t.test(n = NULL, d = NULL, sig.level = 0.05, power = NULL, type = c("two.sample"
,"one.sample","paired"),alternative = c("two.sided","less","greater"))
pwr.t2n.test() t-test (two samples with unequal n)
pwr.t2n.test(n1 = NULL, n2= NULL, d = NULL, sig.level = 0.05, power = NULL,
alternative = c("two.sided","less","greater"))
这里d是Cohen‘s d = ||/