Okay, In this video, we're going to conduct our first one factor at general linear model. So we're going to analyze our first data using that approach. One fact, the general linear model. And we're going to analyze some data that are already found within R. It's a dataset called chick weight. It's a data sets that involves four different diets and 40 different chicks. And the null hypothesis that we're going to be testing here is that diet does not affect chick weight. In other words, if we have these four different diets, our null hypothesis is that the weight will be similar or will not differ among any of those four different groups. Okay. Now this video is going to be long. How HIV a lot to do. So if you want to pause it now, I'll go get yourself a cup of tea or maybe some popcorn and sit back and enjoy the show. But it's going to be long because I'm going to be taking you through every single stage of the analysis and talking about what all the output means. Unless I missed something ORF or forget something. Basically that that's my goals to go through the entire stage of the analysis. Visit every single bit of the output to talk about all the output that we get. And in the ends to be able to formulate biological conclusions based on the data that we have here. Okay, So that's a lot to cover. So this video is going to be my guess, is going to be something about an hour long. Okay, that's my guess. So pause the video, make yourself comfortable or watch this video and several stages, okay? Because we're going to be doing several different tasks throughout this video. And so it might be that you might want to take a break after one of those tasks. Okay. I'm going to keep going though. Okay, I can't take a break. So the first thing we need to do is we'd call up the data. So the data array in a DataFrame called chick weight. And so you can call it the data in your own computer by saying data. And then quotation marks, chick weight, just as you've seen me do here, we're going to run this. And now the first thing you want to do is we want to have a look at the data. Because before we analyze a data, our very first stage of our data analysis is to think about what type of analysis would be appropriate. Okay, so let's look at these data. Let's just look at them. Okay, So R is not giving us all the output. We don't need all the output. Let's have a look at what we have. So here's how the DataFrame is organized. We have four different columns. We have weight. This is the weight of the chicks in this dataset. And we have a column called time. And this column exists because weights have been taken at various times. We also have a column specifying which CIC the data come from. And then we also have a column specifies that diet case. We'll just scroll down here. Lots of data for diet one, we also have data for diet two, et cetera. And we have data for diet 3 and 4 as well. Okay. So let's just look at these data more carefully. We can see here that for chick one, chick one actually has more than one measurement. So chick one is assigned to diet ones. So chick one experienced die at one. But you can see the chick one was measured 21 times, maybe not 21 times, but at times 0, 2, 4, 6, 8, 10, 12, 14, 16, 820, and 21 case. And this is how the keeping track of those time intervals. So we actually have 12 different time, 12 different measurements over time for our first chick. Okay? And just see the same thing is true for these other chicks as well. Given the structure of the data. Can we analyze these data with a one-factor general linear model? Stop and think about that for a moment. Okay, the answer is no. And that's because our data, as they are, currently, violate the assumption of independence. And that's because within a given treatment, we have multiple data points that are not independent of one another because. We've measured the same chick multiple times. Okay? And so as this DataFrame stands, as the status that dataset stands, we cannot analyze these data simply with a one-factor general linear model. If you want to analyze all these data, we'd want to use some other kind of approach. Now, having said that, what I'm gonna do for the sake of this video is I'm going to edit to the dataset so that the data will no longer violate the assumption of equal variance. Sorry, sir, little bit. So that it will no longer violate the assumption of independence. So to do that, what I'm going to do is I'm just going to pull out the last measurement for each check. So I'm just going to pull out the data. So pull out the data in the rows where time is equal to 21, because 21 is always the last time measurement for all of our chicks. Okay? And so what we're going to be analyzing then with this data set is the size of the chicks at the end of the experiment. And we'll be comparing the size of those chicks at the ended the experiment among our four different groups. So let's create a new DataFrame. We'll just call it seats 21. You're stands for CIC 21. And we're going to pull out the data that we want like this. Oops, I've missed something important here. I'll explain what I'm doing in a moment. Okay? So what I'm doing here is you'll notice the square brackets. And the square brackets come after our DataFrame chick weight. So those square brackets allow us to go into the guts of our DataFrame chick weight. And then you'll notice that it has some code before a comma. They may recall when you have a comma inside the square brackets like this that separates information about rose from information about columns. So rows are specified before the comma. Columns are specified after the comma. So what I'm doing here is I'm giving a command then which will apply to the rows of data or two specific rows of data in the DataFrame chick weight. And I'm using a function called a which where what this does, what the which command does. It allows us to specify some logic statement and when that logic statement is met. So when this is true, something will happen. Okay, so what is our logic statement? What a logic statement is we're saying, okay, we want the column in the DataFrame chick weight. We're testing whether or not the the, the data in the column 21 is equal. Sorry, I said that wrong. I was getting ahead of myself. I'm checking whether or not the data in a column time is equal to 21. Okay? And you notice I have this double equal sign here. That standard notation and a lot of programming languages where when you have equals, equals, that means that we are asking whether or not the data in, on this side of the double equals is actually the same as the thing we specified on the right. Okay? So what we're doing here, overalls, we're asking for each row in our DataFrame, whether or not the entry and the time column is equal to 21. And when it is, that causes the which statement to be true. And so when this criterion is true, we will take the data in those particular rows. We know what's rho is because we've given this command before the comma. Those data from those rows will be stored in this new DataFrame. Okay? So let's just run this now. And now let's look at this output. And now you can see that we have just one measurement for each CIK. Okay, so now our data do meets the assumption of independence. Okay? We also have to ask whether or not our data meet the assumption of random allocation. So we want to know whether or not our chicks were randomly allocated to our various treatments. I actually don't know the answer to that. Those details are not. Available to me. So for the sake of this analysis, we're going to assume that they are. Okay. So given that we have an experiment with basically one factor or one treatment type, which is, or one general class of treatments, which is diet. And we have multiple levels of diet. We have four levels of diet. And we're analyzing, you're gonna be analyzing weight, which is a continuous variable. These kinds of data can be analyzed with a one-factor general linear model. So we will proceed with our video. Surprise, surprise. That's our first stage, making sure that our data actually can be analyzed using the approach that we're going to be highlighting. Okay? After we've made sure that our data are appropriate for a particular approach, the next thing you want to do is plot the data. So we're going to plot the data with a boxplot. And to produce a box plot. The first command or the first option we want to get the box plot is we want to tell it what we want to go on the y axis, okay? And we're going to plot weight on the y-axis. So if weight and then a Tilda, which we can think of, which is this little squiggly line that can think of that as being like an equal sign. And then we want to know, wait, how weight varies among our different levels of diet. Okay? And then we want to plot the data from this DataFrame. Check 21. Whoops, swaying to say data equals chick 21. Okay, so here we're just specifying the columns which contain the information that we're going to use to plot. And we specified the DataFrame in which we can find these columns. Now, just one more word on this here. I've referred to wait, as the y variable. And so diet is going to be our x variable. Another way of thinking about this is to say that we put the dependent variable on the left of Tilda, okay? And the independent variable to the right of the tilde. So what's the difference between a dependent variable and an independent variable? Well, the dependent variable is a variable that we think will depend upon the other variable, the independent variable. And in this experiment, We've, or whoever did this experiment presumably set it up specifically to test whether or not changing the diet will change the weight. And so this leads us to see that we would expect wheat to depend upon and diet. That's the hypothesis that we're testing. And so we would say that weight is our dependent variable and diet is our independent variable. I'm making a big deal about this now because we're going to use the same terminology when we run our general linear model. Okay? So let's plot these data. Okay, here is what they look like. That's pretty nice. Let's just make this a bit bigger. It's a bit easier to see. As a quick review, let's also just add individual data points, this plot. So we'll use the function strip chart. And strip chart actually uses the exact same code to start as boxplot. But since there are few other options that we need to include, first of all, the default for strip chart is to plot the data horizontally. Whereas we wanted to plot the data vertically because that's how our data are plotted in the box plot. So we're going to say vertical equals true. We also want to give some scatter to our data so all the data points won't lie on top of one another. So we're going to say method equals jitter. And let's make our data points an open circle. So we'll do that by saying PCH equals 21. We'll say color is maroon and we're going to color the inside of the circles. Risk. So BG stands for background and Bisk. And the last thing we need to do is we need to make sure that this trip charge gets added onto the existing box plot. So I'm going to say add equals true. Okay, so now we can run that and there are our data points. Now, it's really important to plot your data because we can learn a lot from this plot. We're going to use this plots to you to basically form some predictions for what we expect to find in our analysis later on, okay. So the first thing that we can do is we can look at this plot to get a sense of whether or not we think our data, we'll meet our assumptions. So we can test the assumption of normality very generally by just looking at the shapes of these box plots and asking ourselves whether the box plots look fairly symmetrical. This box plot looks fairly symmetrical. Okay, so this looks, this box here has the median pretty much in the middle and these whiskers are pretty similar in length. Okay? So these data are probably consistent with the normal distribution or at least not too far off from it. Same here. These ones not perfect, but rather they're really not bad. Okay? So based on this, I'm going to add some comments here. Expect normal. Okay? Okay, so based on this plot, we expect that our data will meet the assumption of normality. What about the assumption of equal variance? Well, again, if you just look at the general spread in the data here, that general spread of the data to me looks relatively consistent among our different groups. Okay? So we'll say expect Variance. Okay? Alright. Now I want to highlight that I'm doing this just to form our expectations. Srp will find later, looking at a plot like this is not sufficient to test our assumptions. So we're going to test our assumptions more formally later in the video. Okay? There's one other thing that I really want us to see here, which is I want us to make some predictions about the differences between our groups. So notably, it looks like treatment 1 and treatment 3 tends to have the greatest difference between them. So if we find any evidence for a difference, we probably expect it to be between groups 1 and 3. So that's if we find evidence for there being a difference, That's where we'd most expected. Okay? And the last thing that I want to look at is the size of the differences that we expect to find between our various groups. Okay? And we're gonna do this by comparing each of our treatments against treatment 1. So our mean of treatment one is, I don't know, let's say it's around a 175. Okay. Whereas the mean for treatment 2 looks like it's maybe 210. So that would be a difference of about 35. Okay. I'm just eyeballing this. So the difference between 12 is around 35, we're going to guess. Okay. Whereas the difference between 133 looks like it could have a mean of around 250. Sorry, around 275. Pardon me. So that would be a difference of about a 100 between 13. Okay, that's, that's our prediction there. Whereas difference between 14, we might see is around 75, let's say because it looks like this mean might be around 250. Okay. So one to four we're going to say is around 75. We said, okay, we're going to come back to these predictions later. So again, it's important to visualize your data just to give you some sense of what to expect when you go on with your data. Why is that? Sorry, when you go on with your analysis, why is that important? It's important especially with more complicated analyses then like the one we're going to be dealing with in this video. Because if we set out our expectations at the beginning, and then it turns out those expectations are not met later on during the course of our analysis. That might give us reason to worry. So if our expectations at this stage, the analysis did not meet what we find later on. That can be for one of two reasons. Either it can be because our initial expectations were incorrect, or it could be because we've done something funny that we shouldn't have in our analysis. Add, if we find a discrepancy between these initial expectations we find later on, we need to figure out why that difference has occurred. Okay, is it because their expectations were wrong or because you've done something silly liter. Okay, That's why it's important to look at, look at your data before I do anything else. Okay, so now we can start analyzing our data. Okay, so let's just remind ourselves what our data, how our DataFrame set up. So the head command is just allows us to look at the first few rows of our DataFrame. Okay, So this is just to remind me of what are various columns are called. So we're going to run a one-factor general linear model. So we're going to use the lm function and the notation here. And the lm function is exactly the same as we have in the box plot. The first thing we're gonna do is we're going to tell R or tell the lm function what our dependent variable is. And that is weight. Okay? And our independent variable is diet. And remember, we can think about what the dependent and independent variable are by thinking about why you perform the experiments in the first place. We wanted to know presumably whether or not changing our diet changes the weight. By that logic, we would say that diet, we're hypothesizing, sorry, we were hypothesizing that weight will depend upon diet. And said, Wait is our dependent variable and died is our independent variable. Now I need to tell R where our data are there in DataFrame CH 21, I want to see this output. And we're going to see that an object called, I'm going to call it sees 21 dot lm. And I'm just using this nomenclature because it's a really nice way to help me remember where my various output is stored. So see it's 21, that's our DataFrame. And FSA dot lm, that reminds me. That's the output from our linear model is stored, or our linear model for the data from C is 21 is stored in this object. Okay? So let's now run our model. What we want to do now, first thing I want to do after running our model is we want to check our assumptions. And to do that, we can just take the object where we've stored all the output from our linear model. And we're going to put it into the function plot. Okay? So now let's look at this. So this first figure here gives us or allows us to test the assumption of equal variance. And you can see that we have four columns of residuals. Those correspond to the residuals from our four different treatments. And what we're looking for here is to see whether or not the spread of our residuals is generally similar among our four treatments. And indeed they look pretty good. Okay, so, so far, I'm happy that these data meet the assumption of equal variance. This next plot allows us to test the assumption of normality. And we're looking to see whether or not these points all fall along the dotted line. And they actually are remarkably well along this line. So these data are remarkably normally distributed. I would love to have data like these. Okay? Our third plot here gives us another way of testing the assumption of equal variance. Okay? This plot is a more reliable way of checking the assumption of equal variance. And our first plot, what we're looking for is to see whether or not this red line is relatively straight. And in general, it is. The data. We also want to see whether or not they're nicely arranged around the red line. And in general they are. This treatment here is a little bit worrying. But I'm not going to worry too much about that. Okay? So I'm going to say that these data here look just fine. So overall, we're saying that our data meet the assumptions of equal variance and normality, okay, and we're ignoring this last plot. This last plot we could use to check to see whether there are any outliers. But we already know from our box plot that we had no reason to worry about outliers. There were no particularly unusual data points. Okay, so we're ignoring this last plot p because we already knew we needed from our box plot. Okay? So our data now meet the assumptions and so we can now go on to check our results, okay, and I'm going to show you two different types of output that we can get. The first, we're going to get from our using the summary function. Okay? And so we're just taking the output from our linear model. Oops. And it should say, see it's 21. What am I doing? I am a bone head. There we go. We want the, the object where we've stored the output of our linear model, that's CH 21 dot lm. Say put that here and we want to look at a summary of the output from our general linear model. So let's yet that, Okay, here is our output. I'm not going to go over all of the output here. Okay? There's a couple things that I want to really highlight. I'll just go over most of the output. First of all, the output tells us what our actual analysis was. So it gives us our linear model. It then tells us something about the residuals. It tells us the minimum residual, the maximum, the first third quartiles and the median value, the residuals. And then it provides us with estimates of the coefficients. And this is something we're going to spend some time on, okay? Because this is an important thing to understand. Let's focus here, okay? So we have four different rows of output that corresponds to this thing coefficients. What I want you to notice here is that we have our three different, sorry. I'll I'll tell you one bit distracted for a moment. Actually, you know what? I just always just try to, because I realized I forgot to do something. This code that I gave you up here for running the general linear model. It's actually fine for my particular version of Our, but there are recent versions or more recent versions of R where it becomes necessary to actually specifically tell are when we have something that is a factor. So for more recent versions of R, we would want to add this bit of code to our, to our linear model, where we'd want to specifically tell R that these, the information in this column is a factor. Okay? In other words, if you'll remember, diet was coded as 1, 2, 3, 4. We want R to consider though is 1, 2, 3 4s as four different categories, not four different numbers. And it turns out that the data, as they were stored in R in this DataFrame chick weight. They were already set up in such a way that r would automatically recognize Ms. four categories and notice four numbers. That's not always going to be true. So to be certain that our treats these data as categories that we're going to put this term factor around it. Okay, that's not going to change anything. Oops, sorry. I shouldn't have just highlighted that. There we go. Okay, so this is not going to change anything in our output, except we're now going to see that at our output, we have, It's now specifying that diet has been treated as a factor. That's what clued me into the fact that I forgot to do that earlier. Okay? So now our goal is we're going to understand what these coefficients are. Okay? So notice that there are four rows here. Also notice that we have four levels within our factor diet, and we have the first row is called intercept, the second row is called the diet to next Wednesday at three, next one's diet for okay. So as you might expect, her, as you might have figured out, these four rows corresponds to information about our four different diets. Okay? Now, this row here tells us something about diet to, this row tells us something about diet 3 in this row tells us something about diet for what happens? Diet one. Well, diet one is actually included in this first row which we've called it into or which are It's called intercept. What are will do as a standard practice is it will choose one of the levels of a factor, and it will set it as a reference letter, as a reference level. And all of the other levels within that factor will be compared against that reference. So this first row provides us information about diet one. Okay. What kind of information does it give us? Well, let's look at the various bits of information we have here. First of all, have this term in this, which equals 177, which comes into this column estimate. Okay? This value here is the equal to the estimate of the mean value of diet one. Okay? So I'll say it again. This value here is equal to the mean value of diet, I'm sorry, the mean value of growth in diet 1. Okay, so let's just go back to our box plot to get a sense to see, well, that actually makes sense. So this is saying the mean is around a 180. Does that make sense? Yeah, that seems quite plausible. Okay. This next bit here, this is, this equals the standard error for this value of the mean. Okay, So this together, these represent the mean value of growth in treatment one. And this value of 16 is equal to the standard error for the estimate of that mean. Okay? These last bits here, this t value and p-value. These allow us to test whether or not this mean is different from some other value. And you can see we have this absolutely tiny p-value. The p-value is like six times ten to the negative 14. It's a miniscule p-value. So this tells us that we have strong evidence that this mean value is different from something. What's being compared to as being compared against the value of 0. Okay? So all this is telling us is that we have strong evidence that our mean growth in diet one is most certainly different from 0. Is that interesting? Not at all. Because we're measuring live chicks. Live chicks cannot have a weight of 0. That would mean they didn't exist. Okay, so essentially what this first p-value is telling us is that our chicks existed in the first place. They had some value of weight. So that's not interesting. So that's what we get from the first row. What about the second row? The second row tells us something entirely different from the first row. The second row tells us is, is, is it tells us about the difference between the mean value for, for diet 2 and the mean value for diet one. Okay? So here it's saying that the estimated difference between diet 2 and diet 1 is equal to around 37, okay, 36.95. And then here we have a standard error for the estimate of that difference. Okay? So this provides us with one of our effect sizes from our experiments. This tells us, this is an estimate of the effect of diet to, relative to die at one. It gives us a sense of the size of the difference between the mean weight and treatment 2 compared to the mean and treatment 1. And that difference is thirty-six point ninety five. And here we have a standard error for that effect size. This p-value here corresponds to a test of whether or not this difference between diet 2 and diet one different from a value of 0. Okay? And you can see that our p-value is relatively large. And so as a result, we would say that we have very weak evidence that the mean values would differ between diet to indict one. Okay. That's a little bit different for this next row. So for this next year with this now tells us the size, the difference between diet 3 and diet one, okay? And you can see that here, the difference between the mean value of three and the mean value of diet one is about 92. Okay? And here we have an estimate of the standard error for that effect size. And here we have a p-value that tests the hypothesis that the mean value of di three is not different from the mean value of diet one. Okay? And now they can see we have a pretty small p-value. This is relatively small, so this would constitute strong evidence for a difference between diet 3 and diet one. And then we can make the same kind of inference for diet for. Where here we can see that the difference between diet for and diet one is about 60, around 61. And here we have a standard error for that effect size. So this is a standard error for the difference between diet for and diet one or between their means. And here we have a p-value that asks whether or not this difference between the mean of four and the mean of one is likely different from 0. And we have a p-value of around 0.02. I would consider this moderate evidence for a difference between the mean of diet for and the mean of diet one. Okay? So that's how we interpret this output. Okay? That's one thing I want to connect here. And let's go back to our original. When we're looking at our boxplots, we made predictions about the size, the differences among our groups. We said the difference between treatment 1 and treatment 2 would be around 35. And lo and behold, the difference between 12 is turns out to be 36, 0.95. We've made a pretty good guess. And we said the difference between 13 would be around a 100. And lo and behold, the difference is around a 100. And finally, we said the difference between 14 would be around 75. Here, I guess wasn't quite as good. But they weren't that far off. Okay, so this is an example of how we can take our initial predictions from our plot and use that to help us understand the output that we get later on. And also just to check to make sure that we've done things in a reasonable manner. Okay. So that's what I wanted to show you from the output from the summary function. I also want to show you another way of getting an output from this. And that's to use the ANOVA command. And what this allows us to do is to display the output from a general linear model in, in an ANOVA table. Okay? And so let's look at what these results look like. So we've gone over these results or we've gone over this kind of table in our previous videos. Let's just walk through what this means. So this first row here gives us our information about the differences among our diets. This is our among group information. Our degrees of freedom for dy dt is equal to three because we had four groups or four treatments. And so our degrees of freedom is equal to our number of groups minus 1, which is equal to 3. This is our value of our sums of squares for the differences among our groups. This is the sums of squares for the variation within our groups. Calculate our mean square by taking the sum of squares and dividing it by our degrees of freedom. So let's actually just do that. Just to prove to ourselves that we know that we're doing, we're doing. And lo and behold, when we take the means, the sum of squares divided by three, we get the same value, okay? And then we get our F value by kc it I mean squared from among our groups. And dividing it by the mean squared within our groups, which equal to 4.65. And that's what we get here. Okay? And these values we've talked about at length in our other videos, I just want to show you that now you should know how to interpret all of these numbers. Finally, we get our p-value. And this p-value is relatively small. Okay? This a p-value of this magnitude, so it's a round 0.005. And in other videos I've explained that a p-value of around that magnitude we, we consider to be strong or substantial evidence for an effect. So this p-value suggests that we have strong evidence that at least some of the means, at least some of the mean weights will differ among our various diets. Okay, So that's, that's one of our main conclusions here. We now have strong evidence that diet influences the average weight of our chicks. But we don't know which groups differ from which. So to figure that out, we now have to do some post hoc tests. This is our second stage of our analysis of one factor general linear model. Do this, to do this post hoc test. And the kind of post hoc tests we're going to use is called a queue keys test. We're going to use some functions that are in the EM, that means library. If you don't have the EM means library, you can just say, you can say install packages. And then EM means I'm not going to do that because I already have it installed and it takes time to install it. So I don't want to waste time in this video. So instead I'm just going to say lie. Library. Em means. So I'm going to open at the EM means library. And we're going to use three separate functions from the EM means library. The first thing we want to do, so I'll take a step back. What we wants to do using EM means is we want to perform some tests where we compare the mean values among our various diets. Okay, so we want to compare the mean value of diet one, that mean that I have diet 2 and 1 versus 3 and 1 versus four, and also two versus 32 versus 43 versus four. Okay? In order to do that, first of all, have to have our calculate the mean values for these various groups. And it can also calculate some additional information as well that's acquired for this kind of comparison. And so we're going to do that using a function called EM means. Okay, so this function has the same name as a library that it comes from. And when we use the function EM means the first thing that we give it is the object that contains the output from our analysis, which was CHI 21 dot lm. And the second thing that we give it is the name of the independent variable for which you want to calculate our means. So we want to calculate a separate mean for each level of diet. Okay? And so we're gonna tell EM means that the independent variable that we wanted to pay attention to is diet. Okay, So this will cause EM means to calculate separate mean values for each of our levels of diet. Now, we're going to store this output in something going a call C 21. Em means, okay, Yes, I'm just using the same nomenclature as I did above. Just because it's a great way to keep track of what you've done. So we're analyzing a dataset saved 21. And in this object, we're storing the output from the EM Means function. Okay? So let's run this. And now let's see if we get, what do we get in there? Here's what we get. Okay? So we have here four different rows, because we have four different means. So the data in this column are the output and this commerce has EN mean. These corresponds the mean values for each of our four different diets. We also have estimates of the standard error for each of our data points, sorry, for each of our treatments. Okay. I'm going to tell you something a little bit that somebody might seem a little bit obscure. Actually, I'm not going to explain it that way. I want you to notice that the standard error for the mean value of treatment two or diet 2, is exactly the same as a standard error for the mean of treatment 3. If you looked at these two sets of data, would you expect the standard deviation to be exactly the same for these two different groups. So I'll remind you that we calculate standard error as the standard deviation for something divided by the square root of our sample size. Okay, that's how we calculate our standard error. It's unlikely that the standard deviation is identical between these two different groups. So if that's true, why do we end up getting exactly the same standard error estimates? That's because when the EM Means function calculate C standard errors, it does it using the overall estimate of the standard deviation from the whole model. And I'll show you where that comes from. So when we ran this model up here, and we store the output in CH 21 dot lm. Okay. We can do it at, at, at, at, at, at, at. We can extract the estimate of the standard deviation from this model using this function called sigma. Okay, so if we run this, then this is the estimate of the standard deviation for the residuals in our model. Okay? And it's this standard deviation that was used to calculate these estimates of the standard error. Now, why are these two the same? They're the same because they use the same estimate of the standard deviation and they have the same sample size. Why are these different? Y is a standard, are different for diet one and for diet for, well, that's because while there are different, not because they have a different standard deviation, they all use the same standard deviation. The difference because the sample sizes differ in treatment one compared to treatment 2 and treatment 3, and also compared to treatment for. Okay? So that's where these standard errors come from. And that's why if you have exactly the same sample size in all of your treatments, That's why the standard errors for these mean values will always be the same. Okay? The last thing to point out here is that you also have estimates of 95% confidence intervals for these means. This is extremely useful because you can report these means, standard errors and confidence intervals when you report your results. So this is a great way to get that information for reporting your results. So that's useful. What we want to do now is we want to actually conduct our post hoc test. We want to know about the evidence for differences among our various diets. So to do that, we're now going to perform pairwise comparisons among these mean values. So among the means that are stored in this output. So what we're gonna do is we're gonna take that output from the EM Means function and we're going to put it into a function called pairs. Because what this will do is this will now make pairwise comparisons among the different levels of diet. And let's just run this. Okay? So what we have here now is six different tests. We're comparing to one to 21, to 31, to 42 to 32 to 43 to four. These are all the possible ways of comparing these various mean values. Okay? Let's just walk through this output. Okay? So first of all, we have our A1. After we look at specifically what contrast we're, we're looking at, we now have what's called an estimate. So this estimate is equal to, This is our effect size. Okay, so this tells us about the size of the difference between the mean value of treatment 1 and treatment 2. So this says here that the mean, the difference between the mean value of 12 is equal to minus 37. Okay? So it's negative because we're taking the mean of treatments two and subtracting that from the mean of treatment 1. Okay? And you can see here the mean of treatment two is larger than the mean of treatment 1. And so when you subtract something big, something small, you get a negative number. And so we get the difference between these means is equal to 37. And it's negative just because the direction in which these, the subtraction took place. This is an estimate of the standard error for this difference. So this is an estimate of the standard error for this effect size. Okay? And then finally, we have information that allows us to test the hypothesis that this difference between 12 is different from 0. And we can see that we have a p-value that's really, really large. And because it's so large, we would say that we have basically no evidence to say at the mean value of Treat of diet 2 is different from the mean value of diet one. Okay, Now let's look at the comparison for the next contrast. So this compares diet one versus diet 3. This was the case where we said if there's going to be any difference, this is where we'd expect to find it. Okay? The estimate comes out here as minus 92.5. And we have a standard error for that effect size given here. And we get a p-value that tests whether or not. This estimated effect size is likely different from 0. And you can see that we have a fairly small p-value, it's around 0.005. And again, in previous videos I said the p-values of around that magnitude we can consider to be strong evidence or substantial evidence for an effect. So this p-value here says we have strong or substantial evidence for there being a difference between group between diet 1 and 3. Okay. I'm not going to go through this for all of these different rows. I'll just point out that for the remainder of these p-values, we really have no strong evidence for a difference between 14232434. Okay? This output in general though, is useful because what we'd want to do when we report our results, as we would want to report, all the effect sizes, would want to report all of these estimates because they give us our effect sizes. And we'd want to report the standard error for these, for these effect sizes as well. Because we want to report or effect sizes. And these are values that we can report. Now, let's talk a little bit more about these p-values. When we vary. At the very start of our discussion, our very first video about one-factor general linear model. We said that we needed to know how to do a one-factor general linear model. Because we needed an approach that would allow us to analyze data when we have more than two groups in a way where we would not increase our chance of making a type one error. In other words, we wanted to be able to account for the fact that if we're doing many different tests, we did not want the fact we have done those multiple tasks to increase their probability of making a type I error. So when we run a Tukey's test, as we've done here, we know that because, whoops. Because it tells us here in our output. Okay, so we've use a two key method for our test here. We're told that the p values have been adjusted for this output. Okay? And so these p-values habit adjusted according to the two keys method. And they had been adjusted in a way so that overall, our p-values will not lead us to increase the rate of making a type one error. Okay? And that is really the trick that allows this Pro, this approach to analyzing the data to be so much better than to be analyzing these data with a whole series of pairwise comparisons using t-tests. So again, we started out all of our videos in one factory, general, general linear models by saying that we do not want to do a bunch of pairwise comparisons. Because by doing many tasks we increase or opportunity of making a type 1 error. When we go through this process we've just gone through, we can obtain p-values that had been adjusted in such a way that we will not increase our chances of making a type I error. They'd been adjusted in such a way so that overall, the probability of making a type one error is still around 5%. Okay? Just a couple of things I want to point out here before we go into the last stage of our analysis, I want to point out some similarities between this output and the output that we got above. Okay? So let's just compare these two sets of output. So this was the output that we got from our summary function where we gave it the output from the linear model. And we talked about what these different coefficients mean. I just wants to connect to this output, to the output that we got from the pairs function. So when we're looking at these coefficients, we said that this value here represented the difference between diet 2 and diet one. Okay, We saw the difference was 36, 0.95. What do we see up here? The difference between the diet to indict one is 37. Okay? Here we have the difference between diet Three indict one as being 92.5. And here we have a difference of 92.5 and so on. You can also see that the standard errors are also the same. So here are the standard error for this difference of 25.8. And that's what gets down here as well. One thing it is difference though, is the p-values. This p-value here for the comparison between the mean of diet 3 and the mean of diet 1 is equal to 0.0008. This p-value is smaller than the p-value that we got up here for the same comparison between diet 1 and 3. This p-value up here is larger because it has been increase in a way to help us avoid inflating our type one error rate. So this adjustment of our p-values can be, is evident here by comparing the p-values from that we get from our Tukey's test with a p-value that we get from the output of, of our summary function. Now, one of the thing popped into my head that I should have explained before. You'll notice here that I've already talked before about why this estimate is minus 37. And that's because we take the mean of two and subtract that from 12 is larger or the mean value of two is large than one y. Then in our output of our summary function, why is this value positive? Okay? Something I should have mentioned earlier, but I forgot to, has a lot to think about. These values here for the estimates of these coefficients, these values, you can think of them as being what you would need to do to the estimate. So to the estimate of the intercept in order to obtain the mean value for diet 2. Okay? So what I mean here, if we wanted to calculate the mean value for diet to what we do is we take the mean value for diet one. And we would add to that the difference between diet one in diet 2, which is 36 0.95. Okay, whoops. I forgot to copy it. Okay. And so you can see here that by taking this value and adding it to this value, that gives us our mean value for the growth of diet 2. And that is what we get as the mean growth for diet to the mean is 215. According to that output from EM Means. And here we get 214.7. Okay, so same thing, just this output here from the EM Means function that has been rounded. Okay? So just to reiterate, I'm going back to our output for the summary function. These values for the coefficients. So these estimates of our coefficients, these values of 36, 9260, you can think of these as being the values that you would need to add to the value of the intercept in order to obtain the mean value for diet 2, 3, and 4. Okay, So we have now don our comparisons. We've now almost finished your analysis because we've been able to figure out where we have evidence for differences among our various treatment combinations. And we see that we do have substantial evidence for a difference between die one and die at three. But really no strong evidence for differences among any of the other groups or any other comparisons. And we've gone through all of the output. And we even compared output among our various stages. The last thing we'd want to do for, for our analysis is we would want to, oops, don't know what I'm doing here. The last thing we want is we want to obtain confidence intervals for our effect sizes. And we can do that just by taking the output from pairs. So I'll say see it's 21 dot pairs. I'll just run this function again, but store it in this object here. Okay? And so this object here, if we look at it, it's exact same information as you got earlier. What we're now going to do is versus take the output from pairs. And we're going to put it into this function called count int, where what this function will do is it will calculate confidence intervals for our effect sizes. Okay? And here we go. So here we have confidence intervals for our effect size. This is something I want to highlight here. Is that the thing I want to highlight is that these confidence intervals have also been adjusted for multiple comparisons, just like the p-values were adjusted up here. Okay? So these confidence intervals have been adjusted for the fact we're making multiple comparisons. In other words, these confidence intervals have been made to be slightly larger than they otherwise would be because we're doing a series of comparisons. Now, whether or not we want to report adjusted confidence intervals or not. That's a matter of debate. In another video, I'll explain how you can calculate 95% confidence intervals for your effect sizes without making this kind of adjustment for multiple comparisons. We'll talk about that in another video. What I want to highlight here is that we can use these 95 percent confidence intervals for effect sizes to think about the results we obtain. Okay, so let's focus on this result here for the difference between diet 13 are values here a negative, just because we're taking the mean from diet 3 and subtracting that from them, That mean of diet 1. And the mean for 3D was larger than TEN than for one. And so that's why these values are negative or subtracting something large from something small. But in general, it's, let's forget about the negative sign. What these 95% confidence intervals give us is a plausible range of differences for the mean weight between treatment 1 and treatment 3. So we can interpret this output is saying plausibly, the difference in mean weight between diet 1 and 3 could range between 23 grams and a 162 grams. And that would be how we'd wants to present our conclusions. Okay? And of course you would do the same thing for all of our results here. We would not simply focus upon the results that has the strongest evidence for a difference. You'd want to report all of our various comparisons. Okay? So for example, the difference between treatment 3 and treatment for could range from a negative difference of 47 grams all the way up to a positive difference of a 110 grams. Okay, so that would be the range of plausible differences between treatment 3 and treatment for. And you'd want to report all this information in your when you write up your results. And with that, we're just about done. I guess we're gonna go back to our slides. And the last thing that I want to show you is how we might want to report these results if you're writing them up, we'd want, we want to provide a figure of our data, perhaps a figure like this, where we show all of our data. You can see I've got the individual data points presented here. And I've just given a component of what we'd want to report. Okay. So I've started out here by saying our expend provided strong evidence that diet affects Chip Growth. And a base that statement upon the output from our overall one-factor general linear model. So I specify the type of test we've run a one-factor general linear model. We report our F value and we report both degrees of freedom. So this is degrees of freedom among groups and this degrees of freedom for within groups. And then we also report the overall p value that we got from this overall one factor general linear model, okay? This is the p-value that we got from our ANOVA table, okay? And then the rest of these results come from our post hoc tests. Now I've gone on to say, in particular, the shouldn't say four here. So in particular, the largest difference among diets arose when the mean growth and diet 3. And if I give a mean and standard error for diet three, the mean was 20.370 plus or minus 22.6. We got that from the output from EM means. It tends to be greater than the mean for diet one and provide the mean and standard error for it. And then I provide a p-value based on a Tukey's test. That tells us we have strong evidence for a difference between these two means. Okay? And then I go on to talk about the size of this difference. So say the growth under die at three was approximately 50 percent greater than under diet one. Okay? And that's because our mean value for diet Three was way up here. Whereas diet one was around there. And at some point in time of much this must have decided that this value is about 50 percent greater than this value. Okay? A market shrine to the mass of my head right now. But I'm just trying to give a sense of the general size, a difference between these means. I said we'll try and do the math. So about half of this is, let's say it's about a 100. So half of this is about a 100. So if we take a 100 and add it onto that, then we get value here of 270. And so that's where this value 50% greater comes from. Okay? And then I go on to give some insight from a 95 percent confidence intervals where I say where the growth and DEI three was plausibly greater than a diet one by 23.9261.6 grams. And then I specify that, that those plausible values came from 95% confidence intervals for that effect size. And I note that these 95 percent confidence intervals were adjusted for multiple comparisons. Now I've just pulled out one of the results here, highlighted in red that you would want to do something similar for all of your results, you would not only focus on the results that were most striking. Okay, so you'd want to do this for all of them, but I bore everyone to death if I walked you all of those examples. You could present. Your effect size is in a table. We, so you have a table with the effect sizes and the standard error for those effect sizes. And you can also report the 95 percent confidence intervals for those effect sizes. And again, be sure to note whether or not your 95 percent confidence intervals habits have been adjusted due to multiple comparisons. And I've just added this note again just highlights the fact that when you discuss your results, you want to discuss them in terms of a plausible range of effects that you would get. For me 95% confidence intervals. And that everyone is it. I told you this is going to be a long video and it was going to end the video there. So I hope it's been helpful. And it'll say, thank you very much.