🦄 In this #R video we learn to run the paired t-test in R for the means of two paired (dependent) populations (with example). Common applications of the paired sample t-test include case-control studies or repeated-measures designs. We recommend watching these #Statistics videos on the concept of Paired t-Test: ruclips.net/video/Q0V7WpzICI8/видео.html and Wilcoxon Signed Rank Test : ruclips.net/video/v4ZHlTbTOK8/видео.html to learn the concepts better! You can find R practice dataset (BloodPressure) used in this tutorial here: (statslectures.com/r-scripts-datasets ); Want to support us? You can Donate (bit.ly/2CWxnP2), Share Our Videos, Leave Comments and give us a Like 👍🏼! Either way we thank you 😊
Very good video, by the way you teach how to "add a column filed" in R with cbind(). I am new to R and I would say that Adding and computing a column/filed is an easy task in access, oracle, sql server, spss, sas, and so on... in R is not so straightforward as you can see googling "add a column in r data frame": I understand that there are a few different methods depending on the specific package used, in R base is cbind(). I computed the column Diff=After-Before and binded to the BloodPressure data frame and conducted the t test on this field, obtaining the same results as the t test in the video.
If you use the *mutate()* command I. The *tidyverse* packages, it is much simpler. Mutate essentially creates a new variable using existing variables in the data, and will attach it as a new column to the data. The *tidyverse* has, for the most part, sought to make commands and coding in R clearer and more logical
i wonder if we need to do p values adjustment here as we do test multiple times by comparing each pair of the data, so there is a big chance to have a false positive
Hi Mike, Hope you are doing great! When I plot any figure particularly for this video, I am getting too tight plots, I mean the I am not getting vertical dimensions as large as yours, May I know what exactly am I might be doing wrong?
This was wonderfully helpful, thank you! I'm trying to figure out when it's appropriate to code for a random effect and when not to. With the data set that you presented, would it be effective to run a linear mixed model with the subject as the random effect? If not, why?
hey dude your videos have helped me out no end with my uni work. thank you very much. if you answer this it'll be an even bigger help. I don't know if my stats are just wrong and that's why i'm struggling i dunno. basically :- i want to to see if "shade type" (heavy / none) has an effect on the dry biomass of plants leaves and stems ("dry leaves" / "dry stems"). so i have all the mass measurements for the two dry tissues, and I'm trying to compare them to shade type. do i need to perform tests separately for i) Shade Type vs Dry Leaves ii) Shade Type vs Dry Stems OR is there a way of incorporating them both together? Sam
I'm doing a similar style of study, change in patient weight after an intervention. In each case, find the difference in mass for the plant (after-before) then run the t test on that data: change in mass in the shaded group vs change in mass in the unshaded group. Seem reasonable?
as an example, if the same people are measured under 2 different conditions, then their measurements in the two different conditions are parked (or dependant). since they are the same people, their measurements under the different conditions will be correlated. if, instead, you are measuring different people under the different conditions, then the measurements will be independent. the main to think is are you repeatedly measuring the same people? if so, then their measurements will be dependent/paired/related.
I just started watching your lecture today, and with your lecture i did many graphs and perhaps very happy to know that R is very convenient than other that i learned. But i face i problem, with my Boxplots. I manage to draw full boxplot for my data but not for one parameter, such as you showed in your lecture, e.g Smokers...Why?The error message was object 'xy' not found...
Hello. This video is really helpful. I wondered if you could specify how to interpret the results. I ran my statistics while watching this, and was able to get the print out, but am not sure I am interpreting the results. I recoded the data that I have. I am also not sure but it seems as though my students did worst in the "after" data, but this is not the case.
Hi Lynette 3132 . sure, here's what's in the output. the t-value and p-value are for the null hypothesis that the the different in means is 0 (that there is no difference in mean before and after). The confidence interval is for the mean difference...you're 95% confident that the mean difference is in that interval. The way R calculates the MEAN DIFFERENCE depends on the order of entry of the variables. (ie) t.test(Before, After) will return a mean difference using DIFF=Before-After and t.test(After, Before) will return a mean difference using DIFF=After-Before. So, the sign of the difference may change. If the after scores are better on average, then t.test(Before, After) will return a negative mean difference as DIFF=Before-After will result in more negative values. So my guess is that it is likely that. try changing the order you entered the two variables, and you will see the sign of the mean difference change (the summaries will just change sign, but the numeric values will remain the same)
Great tutorial. I have trouble running t.test. An error message appears saying "object (variable" not found, and my is contained in a table like the one in the video. When I use the command Head () it shows me the data correctly. Anyone knows what the issue could be? thanks!
you either need to to specify where the variables are, eg *t.test(data.name$**variable1.name** ~ data.name$variable2.name)* or you must first attach the data using *attach(data.name)* , and then you can call on variables by name *t.test(**variable1.name** ~variable2.name)*
Hi Again. Is there a reason why the output doesn't show the standard deviation and standard error? What does it mean to get a negative value for the t statistic in the print out?
Hi Lynette 3132 , it doesn't return the SD or SE as they are not really relevant to look at. you can have R calculate them if you like though. a negative test statistic means that the mean of the second group is larger than the mean of the first group. (eg) you use the command *t.test(group1, group2, paired=T)*. the numerator of the test statistic is (mean1 - mean2), so the negative test statistic is telling you that the mean for the second group is larger than the mean of the first group. the p-value and/or confidence interval can help you decide if they are statistically significantly different.
Hi Mike, I became a devoted follower of your video by now and i greatly appreciate your support. I was wondering, let say i have to repeat the exact same experiment that you use here on 9 different species of animals. To test if the "before" and the "after" conditions are significantly different from 0 in each species, do I run 9 separate paired t tests? Thanks!
Hi +oacho3 , thanks. and yes, that sounds like a good simple approach to testing that. you may want to correct for multiple comparisons...using something like Bonferroni's correction for Multiple Testing. basically, the adjustment consists of using an alpha of 0.05/9 = 0.00555 for each of the tests, to have overall alpha=Type I error rate of 5%. similarly, this would mean to use 99.444% confidence for each confidence interval, to have 95% confidence over all 9 confidence intervals simultaneously. there are other corrections that can be done, but this one is the simplest. the reason for doing this 'correction' is that with each test/confidence interval, the change of a Type I error (falsely rejecting Ho) increases. this is a way to control the Type I error rate over all tests so that it does not inflate. there are, of course, drawbacks to using an adjustment like this.
+MarinStatsLectures Thank you so much for a great and clear answer! I love your videos. The contents are perfectly paced and focused, flow like a charm, not too complex nor too basics. Is there some way i could show my gratitude on top of telling all my friend about your channel? May I send you a cake from Italy? A bottle of wine?
Thanks oacho3 , we appreciate the sentiment! and while we do love a good bottle of Italian wine, that's not necessary. but thanks very much for the offer ;)
Hi Mike, I am trying to conduct a Paired T test but my R doesn't run it. I wrote this: > t.test (beforeD,afterD,mu=0,alt="two.sided",paired= T,conf.level=0.95) and then appears this legend: Error en t.test.default(beforeD, afterD, mu = 0, alt = "two.sided", paired = T, : data are essentially constant if I conduct the same but paired=F....runs it perfectly but I want paired t test. Do you know what is wrong with this? Thank you . Marcela
Hi Marcela S , its tough to tell from a distance, but saying that the data are constant suggests that the change from before to after for each pair is the same...so there is no estimate of variability...each difference is the same (or constant). thats what it sounds like to me...
🦄 In this #R video we learn to run the paired t-test in R for the means of two paired (dependent) populations (with example). Common applications of the paired sample t-test include case-control studies or repeated-measures designs. We recommend watching these #Statistics videos on the concept of Paired t-Test: ruclips.net/video/Q0V7WpzICI8/видео.html and Wilcoxon Signed Rank Test : ruclips.net/video/v4ZHlTbTOK8/видео.html to learn the concepts better! You can find R practice dataset (BloodPressure) used in this tutorial here: (statslectures.com/r-scripts-datasets ); Want to support us? You can Donate (bit.ly/2CWxnP2), Share Our Videos, Leave Comments and give us a Like 👍🏼! Either way we thank you 😊
Watcher 2:07 minutes soo far. Paused to commend you. Your lecturing style and tempo is very clear and easy to follow, thank you! Hvala Marine!
Thank you this video is very helpful, and contained lots of information
Very clear! Just signed up. Will be looking at your vids while taking a class
good to hear +Ragu Spag !
This video helped me a lot. Thank you
Thank you for showing us the knowledge, it is very valuable to me.
You’re welcome
Thank you for the tutorial!
You're welcome Mariam Benmoussa !
excellent explaination
Very good video, by the way you teach how to "add a column filed" in R with cbind(). I am new to R and I would say that Adding and computing a column/filed is an easy task in access, oracle, sql server, spss, sas, and so on... in R is not so straightforward as you can see googling "add a column in r data frame": I understand that there are a few different methods depending on the specific package used, in R base is cbind(). I computed the column Diff=After-Before and binded to the BloodPressure data frame and conducted the t test on this field, obtaining the same results as the t test in the video.
If you use the *mutate()* command I. The *tidyverse* packages, it is much simpler. Mutate essentially creates a new variable using existing variables in the data, and will attach it as a new column to the data. The *tidyverse* has, for the most part, sought to make commands and coding in R clearer and more logical
@@marinstatlectures Thank You Marin! It's a bit messy getting oriented in R packages, I will try tidyverse as you suggest.
Thank you for the video. it is really helpful
Hi TheChicomito, you're very welcome, glad we could help!
i wonder if we need to do p values adjustment here as we do test multiple times by comparing each pair of the data, so there is a big chance to have a false positive
Great tutorial :)
thanks +Dimitris Pavlakis !
You are a wizard. Please come lecture at UQ. We have only muggles.
lol thanks +Cassandra G ! i'm lecturing at UBC, so if you feel like crossing an ocean, you can come take my courses here :)
hahaha Mike ;)
Hi Sir,
I wonder why my boxplot give me 25 box rather than 2 as your.
Thank you
it is very useful thank you and why using plot sir
Starts at 2:18
t falls in the 99 percent interval, does it mean the hypothesis of before and after have the same mu is true?
Hi Mike, Hope you are doing great!
When I plot any figure particularly for this video, I am getting too tight plots, I mean the I am not getting vertical dimensions as large as yours, May I know what exactly am I might be doing wrong?
This was wonderfully helpful, thank you! I'm trying to figure out when it's appropriate to code for a random effect and when not to. With the data set that you presented, would it be effective to run a linear mixed model with the subject as the random effect? If not, why?
How would you do a Levene Test here? There's no groups...
hey dude your videos have helped me out no end with my uni work. thank you very much.
if you answer this it'll be an even bigger help. I don't know if my stats are just wrong and that's why i'm struggling i dunno. basically :-
i want to to see if "shade type" (heavy / none) has an effect on the dry biomass of plants leaves and stems ("dry leaves" / "dry stems").
so i have all the mass measurements for the two dry tissues, and I'm trying to compare them to shade type.
do i need to perform tests separately for i) Shade Type vs Dry Leaves ii) Shade Type vs Dry Stems
OR
is there a way of incorporating them both together?
Sam
I'm doing a similar style of study, change in patient weight after an intervention. In each case, find the difference in mass for the plant (after-before) then run the t test on that data: change in mass in the shaded group vs change in mass in the unshaded group. Seem reasonable?
Thank you this was a wonderful tutorial . I am still confused , how do we qualify the data as paired or independent ?
as an example, if the same people are measured under 2 different conditions, then their measurements in the two different conditions are parked (or dependant). since they are the same people, their measurements under the different conditions will be correlated. if, instead, you are measuring different people under the different conditions, then the measurements will be independent. the main to think is are you repeatedly measuring the same people? if so, then their measurements will be dependent/paired/related.
Thank you , very well explained !
I just started watching your lecture today, and with your lecture i did many graphs and perhaps very happy to know that R is very convenient than other that i learned. But i face i problem, with my Boxplots. I manage to draw full boxplot for my data but not for one parameter, such as you showed in your lecture, e.g Smokers...Why?The error message was object 'xy' not found...
Hello. This video is really helpful. I wondered if you could specify how to interpret the results. I ran my statistics while watching this, and was able to get the print out, but am not sure I am interpreting the results. I recoded the data that I have. I am also not sure but it seems as though my students did worst in the "after" data, but this is not the case.
Hi Lynette 3132 . sure, here's what's in the output. the t-value and p-value are for the null hypothesis that the the different in means is 0 (that there is no difference in mean before and after). The confidence interval is for the mean difference...you're 95% confident that the mean difference is in that interval. The way R calculates the MEAN DIFFERENCE depends on the order of entry of the variables. (ie) t.test(Before, After) will return a mean difference using DIFF=Before-After and t.test(After, Before) will return a mean difference using DIFF=After-Before. So, the sign of the difference may change. If the after scores are better on average, then t.test(Before, After) will return a negative mean difference as DIFF=Before-After will result in more negative values. So my guess is that it is likely that. try changing the order you entered the two variables, and you will see the sign of the mean difference change (the summaries will just change sign, but the numeric values will remain the same)
Great tutorial. I have trouble running t.test. An error message appears saying "object (variable" not found, and my is contained in a table like the one in the video. When I use the command Head () it shows me the data correctly. Anyone knows what the issue could be? thanks!
you either need to to specify where the variables are, eg *t.test(data.name$**variable1.name** ~ data.name$variable2.name)* or you must first attach the data using *attach(data.name)* , and then you can call on variables by name *t.test(**variable1.name** ~variable2.name)*
@@marinstatlectures Thank you very much! now it works.
Hi Again.
Is there a reason why the output doesn't show the standard deviation and standard error? What does it mean to get a negative value for the t statistic in the print out?
Hi Lynette 3132 , it doesn't return the SD or SE as they are not really relevant to look at. you can have R calculate them if you like though. a negative test statistic means that the mean of the second group is larger than the mean of the first group. (eg) you use the command *t.test(group1, group2, paired=T)*. the numerator of the test statistic is (mean1 - mean2), so the negative test statistic is telling you that the mean for the second group is larger than the mean of the first group. the p-value and/or confidence interval can help you decide if they are statistically significantly different.
Thank you! I love your videos.
Brilliant. Thanks so much
Hi Mike, I became a devoted follower of your video by now and i greatly appreciate your support. I was wondering, let say i have to repeat the exact same experiment that you use here on 9 different species of animals. To test if the "before" and the "after" conditions are significantly different from 0 in each species, do I run 9 separate paired t tests? Thanks!
Hi +oacho3 , thanks. and yes, that sounds like a good simple approach to testing that. you may want to correct for multiple comparisons...using something like Bonferroni's correction for Multiple Testing. basically, the adjustment consists of using an alpha of 0.05/9 = 0.00555 for each of the tests, to have overall alpha=Type I error rate of 5%. similarly, this would mean to use 99.444% confidence for each confidence interval, to have 95% confidence over all 9 confidence intervals simultaneously. there are other corrections that can be done, but this one is the simplest.
the reason for doing this 'correction' is that with each test/confidence interval, the change of a Type I error (falsely rejecting Ho) increases. this is a way to control the Type I error rate over all tests so that it does not inflate. there are, of course, drawbacks to using an adjustment like this.
+MarinStatsLectures Thank you so much for a great and clear answer! I love your videos. The contents are perfectly paced and focused, flow like a charm, not too complex nor too basics. Is there some way i could show my gratitude on top of telling all my friend about your channel? May I send you a cake from Italy? A bottle of wine?
Thanks oacho3 , we appreciate the sentiment! and while we do love a good bottle of Italian wine, that's not necessary. but thanks very much for the offer ;)
Hi Mike, I am trying to conduct a Paired T test but my R doesn't run it.
I wrote this:
> t.test (beforeD,afterD,mu=0,alt="two.sided",paired= T,conf.level=0.95)
and then appears this legend:
Error en t.test.default(beforeD, afterD, mu = 0, alt = "two.sided", paired = T, :
data are essentially constant
if I conduct the same but paired=F....runs it perfectly but I want paired t test.
Do you know what is wrong with this?
Thank you . Marcela
Hi Marcela S , its tough to tell from a distance, but saying that the data are constant suggests that the change from before to after for each pair is the same...so there is no estimate of variability...each difference is the same (or constant). thats what it sounds like to me...
MarinStatsLectures ok Thank you, I will check the data maybe is something wrong...tks.
Mike why didn't we do ....t.test (before~ after) ......in this video...I am getting error for same :(
cause you don't compare categories of a categorical variable unlike before where you checked elements of SAME column
This does not work and no matter what I do there is an error every single time.