So far we have used t-test to illustrate how to evaluate a population mean from a sample mean using null hypothesis significance testing. In fact, t-test is almost exclusively used to test two groups with small sample sizes if they are statistically different in their means or not. Even though the t distribution was known much earlier, it is often credited to William Gossett's 1908 paper under the pen name Student.
So he was a house statistician at the Guinness brewery and was interested in finding an economical way to monitor the quality of stout, which is the main ingredient of Guinness beer then he devised this t-test for the purpose to test the quality of the barley with the sample size as small as 3. The reason why he needed to use the pen name is not clear but one thing that is clear is that it was the company that did not want him to use real name for whatever the reason. So in his publication, Gossett called the t distribution as the "frequency distribution of standard deviations of samples drawn from a normal distribution or a normal population," which implies important properties of the t distribution.
So as I said t statistics is used to compare two sample means whether they are statistically different or not. So when two sample means are compared using the t-test they are tested against the nil difference between the two hypothetical population means from which the sample means are drawn where the null and alternative hypothesis are the following: So the null here. .
. so you're comparing two hypothetical population means mu1 and mu2 and the difference is assumed to be zero in the null or you assume that the those two means are the same. On the other hand, the alternative hypothesis is that no, the difference between the two population mean is not zero in terms of statistically speaking or they are just statistically different in two-tailed way.
But if you predict that the sample mean y the population mean one is greater than population mean two and the difference obviously become positive right and then this is one version of one-tailed test but if you predict that mu1 is less than mu2 then the difference will be negative or this way and this is another directional hypothesis you can test. So t-test involves two variables. So one nominal variable which is called a grouping variable that only has two values because we are comparing two groups with the t-test.
So for example, if you compare male versus female or you want to compare treated group versus control group or whatever group one versus group two. So it involves you know one nominal variable the t-test with two levels of group or two different groups basically. And these groups are compared based on a one single outcome measure which should be at least interval or ratio level of measurement because you need to be able to calculate the mean and standard deviation and so on.
So this outcome variable is shared between the groups that are being compared. So you measuring the same outcome measure and between these two groups so t-test looks at the overall difference which is the average difference in the outcome variable between the groups. So example studies looking at overall difference between the two groups on a single outcome variable will be like say you want to compare the mean visual acuity between the normal and amblyopic patients in terms of their visual acuity.
So this can be an example of t-test here we have a nominal variable which is a grouping variable normal versus amblyopic and the shared outcome variable is the visual acuity. You are comparing the overall difference, not the individual difference, using the t-test. So this is general equation and of the t-test basically.
So in the numerator, we are comparing the observed difference between the two sample means against the expected difference between the population means, which is zero. That is basically zero so we're comparing if the sample mean difference is statistically different from the expected zero difference. So that is the null.
We do not assume that there will be difference in the null when nothing happens so when no change is expected and then this difference divided by the estimate of the standard error of the difference between the two groups. x1 bar and x2 bar. So that is a sample mean difference and this is standard error of the sample mean difference.
So this is just a replaced with the symbols, the observed difference between the two sample mean is just a x1 bar minus x1 x2 bar and then the expected difference between the two population mean is represented by the greek letters, mu1 and mu2 and that difference and this term is just disappears because this is just a zero. So all you're left with in the numerator is just a sample mean difference and then this difference is divided by the standard error of the difference. So that is the general equation of the t-test.
Depending upon whether the individual subjects patients or samples in each group are related or not there are two ways to compare any two treatments, conditions, or groups. So let's take a hypothetical example study where you want to test the efficacy of a new drug to reduce intraocular pressure in ocular hypertensive patients. So one way to design an experiment to test this hypothesis is to recruit a group of ocular hypertensive patients say 100.
Then you can split them into two groups and compare their IOP after treating only one group with the drug. So here this group only gets the treatment with the drug and the control group will get either say placebo or just no drug at all and then after they are treated for a while then their IOP can be compared this way on average. So here the expectation is that the overall IOP is reduced only in the treated group and compared to the control group without the treatment and so this is known as a between subject design and the mode of comparison here is the between subject comparison because the IOPs are compared between the two supposedly independent groups.
Accordingly, this type of comparison or experimental design is also known as independent samples design, unpaired samples design, or unrelated groups or samples design, which means all the same thing. So in the between subject design individual participant or sample is assigned to only one of two conditions or groups and then each individual is tested only once in the assigned condition. So when the outcome variable is measured using the between subject design, an independent samples t-test is used to test the difference between the groups or conditions using Jamovi.
Again here is another equation for independent samples t-test which you don't have to know how to actually do the calculation even just you know looking at this and it looks horrendously complicated So I'm not going to bore you with how to do the calculation using this equation but what I want you to get away with from this slide is this degrees of freedom. So the degrees of freedom for the independent samples t-test is the following: So this n1 represents the number of subjects or samples in the first group and n2 is the number of subjects in the second group. So you add them together so that is basically the total number of patients, subjects in the study.
So if we go back to the previous study and so the total number of subject is hundred. So n1 is this and two is this so if you add these together then it becomes hundred and then you take away two and you take away two because you actually use two sample means in the calculation of the independent samples t statistics. Because the sample mean is fixed for each sample, you have to take away a one from each group.
So that's how you calculate the degrees of freedom. So if you know the degrees of freedom of the t-test and you can figure out the total number of observations or samples of patients in the study even though you cannot really calculate the observations in each group specifically. So here is an example of such between subject design.
So here a hypothesis of ongoing clinical interest is that protein increases the density of macular pigment density and so in a study involving 20 volunteers 10 are randomly assigned to receive Lutein capsules and another 10, the remaining 10 are assigned to receive placebo capsules. So the macula pigment density of each group is measured after 12 months of respective treatments. So here the grouping variable is based on the treatment, Lutein treatment.
So one is treated with Lutein, the other is treated with something else. So that is the nominal variable and the shared outcome measurement here is the macular pigment density and the rationale here is that the macular pigment density should be increased on average in the Lutein group, compared to the placebo group. excuse me So the grouping variable is the Lutein versus placebo and the outcome variable is macular pigment density so here the null is that the macular pigment density after they are treated with the respected respective treatment will be the same so that will be no difference in macular pigment density that is our null but your alternative hypothesis will be no there will be a difference between the two.
So that is a two-tailed alternative hypothesis but if you want to make one tail then you would expect to see the increase in macula pigment density in the group treated with Lutein compared to the group treated with placebo. So that is the alternative hypothesis. Now let's consider the same previous example of testing a new drug supposed to reduce the IOP again.
This time we will use a different design to test the same hypothesis which is known as the within subject design. So in this design you will recruit the same number of ocular hypertensive patients and measure their baseline IOPs and instead of splitting them into two groups as in the between-subject design now you will give them you will give all of them and the drug and measure their IOP again after they are treated for a certain amount of time and compare this treated IOP against the IOP at the baseline. So you're comparing this way and here the expectation is the same as before and the treated IOP will be lower than the baseline IOP if the drug is effective.
Otherwise the drug is not effective but what's different here is the way the IOP measurements are compared. Now the IOPs measured before and after the treatment are related in that they are measured twice on the same individuals. So the IOPs across the conditions are measured on the same group.
So the comparison is made essentially within-subject, which is also known as dependent samples design, paired sample design, repeated measures design, or related samples design. So in this design, the outcome variable is measured repeatedly within the subject. So for example, before and after effect of a drug on the same subject which is kind of a typical example of within subject comparison or the outcome variable measured repeatedly within the related paired or matched subjects or conditions that's compared in a within-subject design.
So for example in many cases unless the disease is or the condition is exclusively unilateral and the right eye and left eye of the same person can be thought of as kind of a related outcome variable because in most cases and they are connected and they work together. So when you say want to compare the left eye and the right eye of the same person then in many cases you can treat them as related groups even though they are not exactly the same entities. So this within-subject design, it is considered that each individual in a group in groups acts as its own control.
Because they are the same individual or they are related and the subject-to-subject variability between the groups or conditions is known to be minimised compared to the between-subject design and in general this is considered as more effective design in terms of the number of subjects required and the ability to detect a difference if there's any compared to the between-subject design. However, when the effect of the first experimental manipulation is permanent or irreversible on the outcome variable then they cannot be tested again on the second manipulation. So in Jamovi, a paired samples t-test is used to test the difference when the within-subject design is used.
And this is the general equation for paired samples t-test. The equation is a looks much more simpler than the independent samples t-test. But this is essentially the t-test for one sample t-test too.
So here the x subscript d bar is the average difference between the two groups or conditions. So this is the mean of the difference between the conditions so in calculating the paired-samples t statistics, you first need to calculate the difference between the conditions and then take the mean of the difference. So that's what it is and the mu subscript d that is the expected difference population difference right but this is again zero okay so this term is just you can just ignore this term and the standard deviation of the difference is sd and this is divided by the number of pairs right here the n is the number of pairs.
So here that means that we have actually 200 measurements before and after but the number of pair is 100. So this is actually pair of measurements and it is that the n is representing and in the paired sample t-test, the number of measurements between the groups cannot be different because they are paired so if you have a different number of measurements or subjects in either the condition then you know it is not really paired samples in a sense okay and the degrees of freedom for pair samples t-test is n minus 1 so n again is the number of pairs in the experiment and minus one because we only have a single mean right mean of the difference in calculating the t statistics that's why we only take away one because there is only single mean involved in calculating the t statistics. So here is an example of the same study we talked about using Lutein but using different design.
So it is exactly the same but they recruited 20 volunteers they measure their macula pigment density at baseline, so before they are treated with Lutein and then they give all 20 volunteers Lutein and for a certain amount of time and see if the treatment actually changes the density of the macula pigment. So in this case the grouping variable is again the treatment, is based on the treatment so it's before and after the treatment so we have two different treatment condition basically. and then the outcome variable is again the macula pigment density right and here the null is that overall the difference in macula pigment density will not be different when compared before and after the treatment so that is the null.
However your alternative hypothesis will be no, there will be a difference in the macula pigment density before and after they are treated with Lutein. More specifically, you expect to see the increase in macula pigment density after they are treated, so the treated macula pigment density should be higher than the baseline macular pigment density in one-tailed way if you want to test that directional hypothesis.