The aim of empirical research in many disciplines is establishing the presence of effects by means of either randomized trials or observational studies if randomization is not possible. For example, a celebrated success of empirical research in epidemiology is the discovery of a causal connection between smoking and lung cancer (Doll & Hill, 1950).

Once the presence of an effect is established, the precise mechanism of the effect becomes a topic of interest as well. A particularly popular type of mechanism analysis concerns questions of *mediation*, that is, to what extent a given effect of one variable on another is direct and to what extent it is mediated by a third variable. For example, it is known that genetic variants on chromosome 15q25.1 increase both smoking behavior and the risk of lung cancer (VanderWeele et al., 2012). A public health mediation question of interest here is whether these variants increase lung cancer risk by directly making the patients susceptible in some way, or whether the risk increase is driven by the increase in smoking.

In psychology, interest in mediation analysis began partly due to the influential S-O-R model (Woodworth, 1928), where causal relationships between stimulus and response are mediated by mechanisms internal to an organism, and partly due to the multistage causality present in many theories in psychology (such as attitude causing intentions, which in turn cause behavior in social psychology). Today, mediation questions are ubiquitous in psychology. Mediation analysis is used to explicate theories of persuasion (Tormala, Briñol, & Petty, 2007a), ease of retrieval (Schwarz et al., 1991; Tormala, Falces, Briñol, & Petty, 2007b), cognitive priming (Eagly & Chaiken, 1993), developmental psychology (Conger et al., 1990), and to explore many other areas. In fact, about 60% of recent papers published in leading journals in social psychology contain at least one mediation test (Rucker et al., 2011).

A standard approach for mediation analysis involves the use of (linear) structural equation models and the so-called difference method (Judd & Kenny, 1981) and product method (Baron & Kenny, 1986). The first method, more common in epidemiology, considers an outcome model both with and without the mediator and takes the difference in the coefficients for the exposure as the measure of the indirect effect. The second method, more common in the social sciences, takes as a measure of the indirect effect the product of (a) the coefficient for the exposure in the model for the mediator and (b) the coefficient for the mediator in the model for the outcome. These methods suffer from a number of problems. First, interpreting linear regression parameters as causal parameters is not appropriate when non-linearities or interactions are present in the underlying causal mechanism and can lead to bias (Kaufman, MacLehose, & Kaufman, 2004; MacKinnon & Dwyer, 1993). Second, it is not always the case that a regression parameter is interpretable as a causal parameter, even if the parametric structural assumptions of linearity and no interaction hold (Robins, 1986). Finally, these methods are not directly applicable to longitudinal settings (where multiple treatments happen over time) and assume no unmeasured confounding.

The aim of this article is twofold. First, we describe recent developments in the causal inference literature which address the limitations of the approaches based on linear structural equations (Baron & Kenny, 1986; Judd & Kenny, 1981). In particular, we show that the linear structural equation approach to mediation analysis is a special case of a more general framework based on potential outcome counterfactuals, developed by Neyman (1923) and Rubin (1974), and extended and linked to non-parametric structural equations and graphical models by Robins (1986) and Pearl (2000). We show how this more general framework avoids the difficulties of the linear structural equations approach and has additional advantages in making strong causal assumptions necessary for mediation analysis explicit. Second, we use the counterfactual framework to develop novel results which extend existing mediation analysis techniques to longitudinal settings with some degree of unmeasured confounding.

Our argument is that to handle increasingly complex mediation questions in psychology and cognitive science, scientists must necessarily move beyond the linear structural equation approach and embrace more general frameworks for mediation analysis. The linear structural equation approach is simply not applicable in complex data analysis settings, and careless generalizations of this approach will lead to biased conclusions.

The article is organized as follows. In section 'Mediation analysis using linear structural equations models', we describe mediation analysis based on linear structural equations in more detail and describe situations where the use of this method leads to problems. In section 'Potential outcomes and mediation', we introduce a causal inference framework based on potential outcome counterfactuals and graphical models, and show how this framework generalizes the linear structural equation framework and correctly handles the problems described in section 'Mediation analysis using linear structural equations models'. In section 'Path-specific longitudinal mediation with unobserved confounding', we describe two motivating examples involving three complications: unobserved confounding, longitudinal treatments, and path-specific effects, and show how the counterfactual framework is able to handle these complications with ease. Section 'Conclusions' contains the discussion and our conclusions. The general theory necessary to solve examples of the type shown in section 'Path-specific longitudinal mediation with unobserved confounding' is contained in the supplementary materials.