  The increase in the use of mobile and wearable devices now allows dense
assessment of mediating processes over time. For example, a pharmacological
intervention may have an effect on smoking cessation via reductions in
momentary withdrawal symptoms. We define and identify the causal direct and
indirect effects in terms of potential outcomes on the mean difference and odds
ratio scales, and present a method for estimating and testing the indirect
effect of a randomized treatment on a distal binary variable as mediated by the
nonparametric trajectory of an intensively measured longitudinal variable
(e.g., from ecological momentary assessment). Coverage of a bootstrap test for
the indirect effect is demonstrated via simulation. An empirical example is
presented based on estimating later smoking abstinence from patterns of craving
during smoking cessation treatment. We provide an R package, funmediation,
available on CRAN, to conveniently apply this technique. We conclude by
discussing possible extensions to multiple mediators and directions for future
research.
