[R] sample size for t-tests
Adaikalavan Ramasamy
ramasamy at cancer.org.uk
Wed Sep 1 11:47:09 CEST 2004
Look into the code of power.t.test in the stats package. For example,
the sample size for two-sample t-test, two-tail testing and strict
interpretation of tail probability can be found by solving the following
equation iteratively :
\begin{equation}
1 - \beta = \Pr ( t_{v,ncp}^{*} < t_{v, \alpha/2 } )
+ \Pr ( t_{v,ncp}^{*} > t_{v, 1 - \alpha/2 } )
\end{equation}
where :
1) $t_{v, \alpha/2}$ is the $\alpha/2$ quantile of a central
t-distribution with $v$ degrees of freedom and $v = n1 + n2 - 2$
2) $t_{v,ncp}^{*}$ follows a non-central t-distribution $v$ degrees of
freedom and non-centrality parameter of $ncp$
3) non-centralitity parameter in 2) estimated by
$ncp = \delta / ( \sigma \sqrt{ \frac{1}{n_1} + \frac{1}{n_2} } )$
As usual, $alpha$ and $beta$ represent type I and type II error and
\delta, \sigma represents the desired difference in group means and
variance.
This would be explained in a textbook but none comes to my mind at the
moment. There is an approximate analytical solution based on normality
assumption but the results are very close for large sample sizes. It is
better to use the exact equation as the computations (via uniroot) is
fast anyway.
Regards, Adai
> On Tue, 2004-08-31 at 18:49, Caimiao Wei wrote:
> > Dear all,
> >
> > Could any one please tell me the exact formula R uses to calculate the sample size for one-sample and two-sample t-tests? Thanks,
> >
> > Caimiao
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> >
More information about the R-help
mailing list