One Sample T Tests

The R function t.test (on-line help) does t tests and confidence intervals.

The example done on the confidence intervals page also does a test, although the default test is not necessarily the one you want.

Other arguments to the t.test function are mu, which specifies hypothesized value under H0 other than zero, and alternative, which allows for upper-tailed, lower-tailed, or two-tailed tests (as can be seen from the example above, the default is two-tailed).

Here are the one-tailed tests

Here is one with a different null hypothesis

The arguments mu and alternative are used similarly for two-sample tests.

Power Calculations

Normal Reference Distribution

These are the examples done in the slides for the class (slides 186–194, deck 2).

does the upper-tailed test and

does the two-tailed test.

Comments

The R functions pnorm and qnorm (on-line help) do the DF and inverse DF of the normal distribution.

The R keyword for (on-line help) indicates a loop. In this example, the first curve command draws the first power curve for sample size n[1], and the second curve command draws the remaining power curves for sample sizes n[2], through n[length(n)].

The R function curve (on-line help) draws curves. In the first argument x is a free variable ranging between the values of the from and to arguments.

The (on-line help for topic plotmath) explains what

    xlab = expression((theta - theta[0]) / tau)
does.

Student T Reference Distribution

These are the examples done in the slides for the class (slides 195–201, deck 2).

does the upper-tailed test and

does the two-tailed test.

Comments

The R functions pt and qt (on-line help) do the DF and inverse DF of the t distribution.