## What is mediation?

There are many ways to define mediation and mediators. Hereâ€™s one way: Mediation is the process by which one variable transmits an effect onto another through one or more mediating variables. For example, as room temperature increases, people get thirstier, and then they drink more water. In this case, thirst transmits the effect of room temperature on water drinking.

## What is an indirect effect?

The indirect effect quantifies a mediation effect, if such an effect exists. Referring to the thirst example above, in statistical terms, the indirect effect quantifies the extent to which room temperature is associated with water drinking indirectly through thirstiness. If youâ€™re familiar with interpreting regression coefficients and the idea of controlling for other variables, then you might find it intuitive to think of the indirect effect as the decrease in the relationship between room temperature and water drinking after youâ€™ve partialed out the association between room temperature and thirtiness. In other words, how much does the coefficient for room temperature decrease when you control for thirstiness?

## Model and Conceptual Assumptions

• Correct functional form. Your model variables share linear relationships and donâ€™t interact with eachother.
• No omitted influences. This one is hard: Your model accounts for all relevant influences on the variables included. All models are wrong, but how wrong is yours?
• Accurate measurement. Your measurements are valid and reliable. Note that unreliable measures canâ€™t be valid, and reliable measures donâ€™t necessairly measure just one construct or even your construct.
• Well-behaved residuals. Residuals (i.e., prediction errors) arenâ€™t correlated with predictor variables or eachother, and residuals have constant variance across values of your predictor variables. Also, residual error terms arenâ€™t correlated across regression equations. This could happen if, for example, some omitted variable causes both thirst and water drinking.

## Libraries

``````library(tidyverse)
library(knitr)
library(lavaan)
library(psych)
library(MBESS)``````

## Data

I took the data from Table 3.1 in Mackinnon (2008, p.Â 56) [.csv]

``thirst_dat <- "data/mackinnon_2008_t3.1.csv" %>% read_csv()``

## Visualize relationships

Itâ€™s always a good idea to look at your data. Check some assumptions.

``````thirst_dat %>%
select(room_temp, thirst, consume) %>%
pairs.panels()``````