Today's class, we're going to talk about interactions. The term "interaction" has a very specific meaning when talking about experiments. As mentioned in the previous class, I'm going to add a term to our prediction model, and the interaction term is that one. Now, some people take a while to understand what interactions are. I'm going to give you a very simple example to start with, and then some actual numbers to look at an example more thoroughly. So, assume your hands are covered with dirt or oil. And we know if you wash your hands with cold water, it's going to take a while to clean them, much longer than if you wash with hot water. So, the temperature of the water has a significant effect on the time taken to clean your hands. Now consider the case when washing your hands with cold water, but using soap. If you use soap, it will reduce the time taken to clean your hands than if you did not use soap. So, it's clear, when using cold water, and adding soap, you're going to reduce the time to clean your hands. Now consider what might happen if you use hot water and add soap. The time taken to clean your hands with hot water and soap is greatly reduced. We say there's an interaction between soap and the temperature of the water. The effect of warm water enhances the effect of soap. Conversely, the effect of soap is enhanced by using warm water. This is an interaction that works to help us reach our objective faster. All that "interaction" means is the effect of one factor depends on the level of the other factor. In this example, the effect of soap is different depending on whether we were using cold water or hot water. Interactions are also symmetrical. The soap's effect is enhanced by warm water. Also, the warm water's effect is enhanced by soap. So, "symmetry" means that if soap interacts with water temperature, then we know the water temperature factor interacts with the soap factor. There are examples of interactions that actually work against each other and cancel each other out. And we'll see some of that in the upcoming videos. Today's class is going to consider interaction using a baking experiment. We're going to look at ginger biscuits. Now, ginger biscuits are quite possibly my favourite type of biscuit. And the results we're going to consider are from a student that I had in my class a few years ago, where she considered 3 outcome variables. The first variable was taste. The second outcome was break strength or breakability of the biscuit. And the third outcome was the breakability of the biscuit after one week. Why did she measure three outcomes? Here's a great piece of advice when you run experiments. Even if you only have one outcome variable as your current objective, try to measure as many outcomes as you possibly can because you never know in future which outcome you will be interested in. It's very expensive to repeat experiments, so measure as much as you can the first time, even variables you're not interested in right now. So, let's go back to that taste outcome. And ignore the other two outcomes for now. Taste is obviously a subjective measurement. So these results are going to be very specific to my student's taste. I have a friend who is a professional taster and he was trained for over six months before he was considered to be qualified enough to taste foods for a large Canadian grocery store. Students in my class are not qualified tasters. So this outcome is very subjective. What that means is that if you repeated these experiments, your answers may actually be quite different. So, back to those ginger biscuits. The two factors that were considered were the baking time, and the type of sugar. Here's the recipe for you. The baking time values that the student used were 8 minutes and 14 minutes, and for the type of sugar she chose either molasses or honey. All other settings for the recipe were left as shown here on the screen. Here are the taste results. 3, 5, 4, and 9. "3" is a very bad tasting biscuit and "9" is really good. This is on a scale from 1 to 10. It's clear that the best tasting biscuits were produced when using molasses and a baking time of 14 minutes. The worst tasting biscuits were those made with honey and baked for a short time of 8 minutes. Those had a value of 3 on the taste scale. Start with an "interaction plot" for the two types of sugars. And we see the lines here are divergent. They're definitely not parallel this time. When the lines are not parallel, this is evidence of interaction. If we change the choice of the variable on the horizontal axis to be sugar and redraw the plots, we have one line for short cooking times and another line for longer cooking times and again, we will observe divergence, again demonstrating that there's interaction. Recall that we had said earlier, interactions imply the effect of one variable depends on the level of the other variables. Our conclusion here is that the effect of sugar type depends on the duration that it is baked for. In other words, the time factor. Another visualization I showed you last time was the "contour plot". I showed you how to draw contour plots in class 2A. And when we draw a contour plot for this system, we notice that there's some non-linearities here. In order to connect these lines, we need to have curves in them to make it work. We use the term curvature to describe this sort of non linearity. And curvature is evidence that there might be interaction in our system. Let's try to quantify the system numerically. We're going to apply what we learned in the previous class, class 2B, and see if we can predict taste. Start with the main effects. "Main effects" is a term we use to describe how the factor will affect the outcome. In this example, there are two factors, so there's two main effects. Let's start with baking time. Always quantify this main effect from high to low. So, when using molasses, the main effect is 9 - 4, which equals 5. And when we use honey, it is 5 - 3, which equals 2. So we can say, on average, the main effect of time is to increase taste by 3.5 units. But remember, only report half this number, which is 1.75. Next, we examine the main effect of sugar. When we move from high to low, we can see this is 9 - 5, that's 4, and the change at low baking times is 4 - 3, which equals 1. So, the average of 4 and 1 is 2.5. There's a 2.5 unit change on average in taste when we go from using honey to molasses. We report half the value again. Okay, so now is where it might get a little bit messy. Let's try to quantify this interaction numerically. Keep factor B at its high level and note that we have a change of five units when A is changed. Now put factor B at its low level and we see a change of 2 units. There's a bit of a discrepancy here, "5" over there and "2" down here. A system with no interaction will have these individual effects of A, roughly the same. But 5 and 2 are actually quite different. Interaction is mathematically defined as half the difference, when factor B is high and subtract from it when factor B is low. Let's show that mathematically. That is, 5 - 2 and then divide that by 2, in other words, 1.5. And, by convention again, we report only half of that value, 0.75. Remember we said that interactions are symmetrical. So, let's try it again by looking at it from the other perspective. Compare the difference for factor B at high and low levels of A this time. So, the effect of sugar type at long cooking times is a difference of 4 units. That same difference, when using short cooking times, is only a difference of +1. Those two values are quite different, +1 and +4. The half difference this time is 4 - 1 divided by 2, and that's a value of 1.5. The same value as before. Again, we report only half of this, so a 0.75. So, let's go ahead and add that term to our prediction model. So far, our prediction for taste is 1.75 times xA plus 1.25 times xB. The interaction value was 0.75, and we multiply that by xA and xB. It is symmetrical and multiplicative. There's only one other term missing from this prediction equation, and that's our baseline taste. That baseline is the average of all four values. So 3 + 5 + 4 + 9 and then divide all of that by 4, that's equal to 5.25. And we'll add that number right up here at the front. So let's take a look and see how well our predictions work. Try to predict the taste when using molasses and a cooking time of 8 minutes. For that case, xA is equal to -1 because of 8 minutes and xB is equal to +1 because we are using molasses. That's our coding. So that predicted taste is 5.25 + 1.75 times -1 plus 1.25 times +1, plus this interaction of 0.75 times -1 times +1. This shows our baseline taste is 5.25, but using short baking times removes 1.75 from our taste score. Using molasses improves the taste by 1.25 units. And then the interaction works against us, unfortunately, and subtracts off 0.75 units. So, our total prediction here is 4. Try it again but using baking times of 14 minutes so that xA is a +1. So, now our prediction is 5.25 plus an additional 1.75 for baking time, plus 1.25 for using molasses, and now the interaction works in our favour by adding 0.75 units for taste. This gets us a cumulative total of 9 units. Now, this all may seem very messy but it's well worth it because what we get is a really good prediction model that accounts for the interactions in our system and the main effects. A system with no interactions would have this term over here equal to zero. Interactions involving two variables are called a two factor interaction. And they obviously occur when we have two factors. But two factor interactions also occur in systems when we have 3 or 4 or more factors. We'll see these guys cropping up several times. In fact, two factor interactions occur very frequently in real systems, so make sure you're comfortable understanding them, at least conceptually. Maybe go back to that soap and water example and really try to figure what an interaction means in that case. Interactions imply that the main effect of one factor depends on the value of another factor, and that's really all you have to remember about an interaction. Also, bear in mind that interactions are symmetrical, and one way we can see that, over here, is mathematically. xA times xB is the same as xB times xA. Now, let's just step back and take one important piece of advice away from today's video. Never do any work without critically thinking about the interpretation of these numbers. These are not just numbers. What is the message that they are telling us? We can see we get better taste if we increase the baking time from 8 minutes to 14 minutes. But what will happen to taste if we go and cook for 16 minutes, 18 minutes, or 20 minutes? Will taste really keep improving? Think of all those burnt biscuits you're going to create. We saw that we improved taste by changing from honey to molasses. But why was this? Does that actually make sense? Remember, taste is subjective. I think this student preferred the taste of molasses over honey. Molasses is certainly a more complex ingredient than honey. I prefer molasses as well, but many of my friends don't like the taste of it at all. Another important point, how do we interpret the interaction? Is there any reason why we got a better taste with molasses at longer baking times? Both experiments with molasses had a better taste after all. But it seems like molasses, when cooked for a longer time, brings out a much better taste than honey. Perhaps the chemical reactions that are occurring during that baking in the oven give it a better taste. And because of the longer duration, they're given longer times for those reactions to complete. That's possibly what leads to better taste. Okay, so that's it for today's class, all about interactions. I hope you get a chance to review this a second time. It's not always the easiest concept to understand the first time around. So, please feel free to review it again.