In statistics, moderation occurs when the relationship between two variables depends on a third variable. In this case, the third variable is referred to as the moderating variable or simply the moderator. The effect of the moderating variable is often characterized statistically as an interaction. That is, a third variable that effects the direction and or strength of the relation between your explanatory and response variable. So does type of exercise program effect the direction or strength of the relationship between diet and weight loss? The standard way of asking this question in the context of analysis of variance, is to move to the use of a two-way or two factor analysis of variance, rather than the one-way or one factor ANOVA that we've been using. Instead, we're going to take a less standard approach that can be consistently used across each of the inferential tolls. That is, ANOVA, Chi Square, and Pearson Correlation. In each of these contexts, we're actually gonna be asking the question is our explanatory variable associated with our response variable, for each population subgroup or each level of our third variable? That is are diet type and weight loss associated for those doing the cardio exercise program? And are diet and weight loss associated for those using the weight training program? >> To accomplish this, we are going to run two separate ANOVAS, one for each level of a third variable. That is for each exercise program. Syntax to be added to the program is listed here. We need to first create new data frames with only the subsample of interest. That is either cardio or weights separately. When we run the analysis of variants, you'll see the following results. The ANOVA table examining the relationship between diet and weight loss for those in the cardio exercise group shows a large F value, and a significant p-value. When examining the means table we see that for those involved in the cardio exercise program, diet A is associated with greater weight loss, 20.5 pounds on average, than diet B, 7.1 pounds on average. The association between diet and weight loss for those involved in the weight training exercise program is also significant. It has a large F value and a significant P value. However, the means show that the association is in the opposite direction. For those involved in weight training, diet B is associated with greater weight loss, 11.5 pounds compared to diet A, only 8.8 pounds. >> Here, these results are shown graphically. As you can see, the relationship between diet and weight loss depends on which exercise program is being used. When using cardio, diet A is significantly better for weight loss than diet B. When using weights, diet B is significantly better for weight loss than diet A. Thus we can say there's a significant statistical interaction between the variables diet and weight loss. And the type of exercise, our third variable, moderates the association between diet and weight loss. >> Suppose that we did not evaluate exercise as a possible moderator. And instead focused only on the association between diet and weight loss for the entire population. Based on this graph obviously we would have incorrectly concluded that diet A is better than diet B. As we now know that is only true if we're looking at the cardio group.