Single Sample TTests
TTests are inferential statistical tests that allow you to draw conclusions about data. There are three types of ttests and they are used in very specific situations.
A single sample ttest is used when one wants to compare a sample mean to a known population mean.
Note, the logic of null hypothesis testing is not covered in this assignment. At this point, you should know that a test statistic will be calculated which will result in a p value. In simple terms, for this test if p is less than 0.05 (the most conventional alpha level that is used) then you would believe that your sample mean is different from the known population mean. Conversely, if p is greater than 0.05 then you would conclude that the sample mean and the population mean do not differ. Direction of the effect, is significant, is determined by examining the actual values of the sample mean and the population mean, i.e., is the sample mean smaller or greater than the population mean.
For example, you believe that males in Victoria, B.C. eat less calories on average than the the national average. The national average is a known population mean - it is a value you can ascertain from prior research, i.e., Stats Canada. You do some research and find out from Stats Canada that the average active male aged 19-30 eats approximately 3000 calories per day - your known population mean. So, you go out and determine the average number of calories eaten by a group of 50 19-30 year old active males in Victoria. That data is HERE. You want to conduct a single sample ttest to estimate p for this comparison.
1. Load the data into a table called calorie.data. Note, I am not going to bother to rename the one column of data, so the data is simply in calorie.data$V1
2. Running a single sample ttest is simple:
analysis = t.test(calorie.data$V1, mu = 3000)
This command tells R to conduct a single sample ttest of calorie.data$V1 against a known population mean of 3000. By specifying mu, R will automatically know to treat this as a single sample ttest.
3. To see the results of the ttest, simply type:
print(analysis)
You should see that the results of this single sample ttest are significant using a conventional alpha of 0.05 as p = 0.01781, which is less that p = 0.05.
Make sure you understand what degrees of freedom are. For a single sample ttest the degrees of freedom are: df = n -1.
Assignment Question
The assignment questions for the sections 5A, 5B, and 5C can be found at the end of section 5C.
A single sample ttest is used when one wants to compare a sample mean to a known population mean.
Note, the logic of null hypothesis testing is not covered in this assignment. At this point, you should know that a test statistic will be calculated which will result in a p value. In simple terms, for this test if p is less than 0.05 (the most conventional alpha level that is used) then you would believe that your sample mean is different from the known population mean. Conversely, if p is greater than 0.05 then you would conclude that the sample mean and the population mean do not differ. Direction of the effect, is significant, is determined by examining the actual values of the sample mean and the population mean, i.e., is the sample mean smaller or greater than the population mean.
For example, you believe that males in Victoria, B.C. eat less calories on average than the the national average. The national average is a known population mean - it is a value you can ascertain from prior research, i.e., Stats Canada. You do some research and find out from Stats Canada that the average active male aged 19-30 eats approximately 3000 calories per day - your known population mean. So, you go out and determine the average number of calories eaten by a group of 50 19-30 year old active males in Victoria. That data is HERE. You want to conduct a single sample ttest to estimate p for this comparison.
1. Load the data into a table called calorie.data. Note, I am not going to bother to rename the one column of data, so the data is simply in calorie.data$V1
2. Running a single sample ttest is simple:
analysis = t.test(calorie.data$V1, mu = 3000)
This command tells R to conduct a single sample ttest of calorie.data$V1 against a known population mean of 3000. By specifying mu, R will automatically know to treat this as a single sample ttest.
3. To see the results of the ttest, simply type:
print(analysis)
You should see that the results of this single sample ttest are significant using a conventional alpha of 0.05 as p = 0.01781, which is less that p = 0.05.
Make sure you understand what degrees of freedom are. For a single sample ttest the degrees of freedom are: df = n -1.
Assignment Question
The assignment questions for the sections 5A, 5B, and 5C can be found at the end of section 5C.