An R Introduction to Statistics

Two-Tailed Test of Population Mean with Unknown Variance

The null hypothesis of the two-tailed test of the population mean can be expressed as follows:

μ = μ0

where μ0 is a hypothesized value of the true population mean μ.

Let us define the test statistic t in terms of the sample mean, the sample size and the sample standard deviation s :

    ¯x− μ0
t = s∕√n--

Then the null hypothesis of the two-tailed test is to be rejected if t ≤−tα∕2 or t tα∕2 , where tα∕2 is the 100(1 α) percentile of the Student t distribution with n 1 degrees of freedom.

Problem

Suppose the mean weight of King Penguins found in an Antarctic colony last year was 15.4 kg. In a sample of 35 penguins same time this year in the same colony, the mean penguin weight is 14.6 kg. Assume the sample standard deviation is 2.5 kg. At .05 significance level, can we reject the null hypothesis that the mean penguin weight does not differ from last year?

Solution

The null hypothesis is that μ = 15.4. We begin with computing the test statistic.

> xbar = 14.6            # sample mean 
> mu0 = 15.4             # hypothesized value 
> s = 2.5                # sample standard deviation 
> n = 35                 # sample size 
> t = (xbarmu0)/(s/sqrt(n)) 
> t                      # test statistic 
[1] 1.8931

We then compute the critical values at .05 significance level.

> alpha = .05 
> t.half.alpha = qt(1alpha/2, df=n1) 
> c(t.half.alpha, t.half.alpha) 
[1] 2.0322  2.0322

Answer

The test statistic -1.8931 lies between the critical values -2.0322, and 2.0322. Hence, at .05 significance level, we do not reject the null hypothesis that the mean penguin weight does not differ from last year.

Alternative Solution

Instead of using the critical value, we apply the pt function to compute the two-tailed p-value of the test statistic. It doubles the lower tail p-value as the sample mean is less than the hypothesized value. Since it turns out to be greater than the .05 significance level, we do not reject the null hypothesis that μ = 15.4.

> pval = 2  pt(t, df=n1)  # lower tail 
> pval                      # twotailed pvalue 
[1] 0.066876