Section 21 Testing Mean: Unknown variance
21.1 One Sample, Unknown Variance
Hypothesis test on the mean of a Normal distribution when the variance is unknown
21.2 Problem
Test if the average body weight of 6-year old children in the UK is different from the hypothesised population mean of 22 kg
Hypothesised Population Mean: \(\large \mu = 22\)
21.3 Steps
- Identify the parameter of interest: Population mean \(\large \mu\)
- Define \(\large H_O\) and \(\large H_A\)
\[\large H_O: \mu = 22\]
\[\large H_A: \mu \ne 22\]
- Define a significance level \(\large \alpha\)
\[\large \alpha = 0.05\]
- Calculate an estimate of the parameter
Sample Mean: \[ \large \bar{x} = \frac{1}{n}\sum\limits_{i=1}^{n} x_{i} \]
Sample Variance: \[ \large Var(X) = s_x^2 = \frac{1}{n-1}\sum\limits_{i=1}^{n} (x_i-\bar{x})^2 \]
Standard Error of Mean: \[ \large sd(\bar{x}) = \frac{s}{\sqrt{n}}\]
- Determine an appropriate test statistic, its distribution when \(\large H_O\) is correct, calculate the value of test statistic from the sample
Distribution of the test statistic
\[ \large t_{Cal} = \frac{\bar{x} - \mu}{SE(\bar{x})} = \frac{\bar{X} - \mu}{s/\sqrt{n}} \]
The test statistic \(\large t_{Cal}\) has a \(\large t\) distribution with (n-1) degrees of freedom.
- Note - The test statistic represents the ratio of signal to error - The test statistic is centred and scaled
- Obtain the probability under the distribution of the test statistic (two-tailed probability)
\[\large 2*pt(q=|t_{Cal}|, df=(n-1), lower.tail=FALSE)\]
- Compare the observed probability given the \(\large \alpha\) and conclude
Find the probability that \(\large t\) is less than or equal to \(\large |t_{Cal}|\) from \(\large t\) distribution with \(\large (n-1)\) degrees of freedom.
21.4 Exercise
Generate a random sample of size 30 from a Population with Mean = 20 and SD = 4.
Write a function to test the hypothesis if the average body weight of 6-year old children in the UK is different from the hypothesised population mean of 22 kg assuming the variance is unknown.
Use the R function
t.test
to implement the one-sample t-test and compare your results.