  In animal behavior studies, a common goal is to investigate the causal
pathways between an exposure and outcome, and a mediator that lies in between.
Causal mediation analysis provides a principled approach for such studies.
Although many applications involve longitudinal data, the existing causal
mediation models are not directly applicable to settings where the mediators
are measured on irregular time grids. In this paper, we propose a causal
mediation model that accommodates longitudinal mediators on arbitrary time
grids and survival outcomes simultaneously. We take a functional data analysis
perspective and view longitudinal mediators as realizations of underlying
smooth stochastic processes. We define causal estimands of direct and indirect
effects accordingly and provide corresponding identification assumptions. We
employ a functional principal component analysis approach to estimate the
mediator process, and propose a Cox hazard model for the survival outcome that
flexibly adjusts the mediator process. We then derive a g-computation formula
to express the causal estimands using the model coefficients. The proposed
method is applied to a longitudinal data set from the Amboseli Baboon Research
Project to investigate the causal relationships between early adversity, adult
physiological stress responses, and survival among wild female baboons. We find
that adversity experienced in early life has a significant direct effect on
females' life expectancy and survival probability, but find little evidence
that these effects were mediated by markers of the stress response in
adulthood. We further developed a sensitivity analysis method to assess the
impact of potential violation to the key assumption of sequential ignorability.
