% Time-stamp: <2009-10-10 21:13:34 chl>
\documentclass[a4paper, 11pt]{scrartcl}

\usepackage[english]{babel}
\usepackage{xcolor}
\usepackage{xltxtra}
\usepackage{fontspec}
%\usepackage{lscape}
\usepackage{rotating}
\usepackage{subfigure}
\usepackage{multirow}
\usepackage[super]{natbib}

\definecolor{DarkSkyBlue}{rgb}{0.20,0.39,0.64}

\usepackage[dvipdfm, bookmarks, colorlinks, breaklinks, pdftitle={Thérapie génique},
    pdfauthor={Christophe Lalanne}]{hyperref}
\hypersetup{
	linkcolor=DarkSkyBlue,
	citecolor= DarkSkyBlue,
	filecolor= DarkSkyBlue,
	urlcolor= DarkSkyBlue
}

\setmainfont[Mapping=tex-text]{Palatino}
%\setmainfont[Mapping=tex-text]{Gill Sans}
%\setmainfont[Mapping=tex-text]{Optima}
%\setmainfont[Mapping=tex-text]{Monaco}

\typearea[12mm]{11}


\usepackage[parfill]{parskip}  
%\usepackage[xetex]{graphicx}
%\usepackage{epstopdf}
%\DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 `dirname #1`/`basename #1 .tif`.png}

\title{How to test for mediation and moderation effects in biomedical research}
\author{Christophe Lalanne\thanks{This document is available on
    \href{http://www.aliquote.org}{www.aliquote.org}. Any suggestion
    for improvement is welcome.}}
\date{Octobre 2009}        

\begin{document}
\maketitle

\section{Overview}
\subsection{The multiple regression framework: A look into causal pathways}
Figure~\ref{fig:outline} gives an outline of the different situations
a researcher may faced when applying a multiple regression model,
especially for data coming from an observationnal study or with
community samples. 

\begin{figure}[htb]
  \centering
  \includegraphics[width=.65\textwidth]{PEP_Fig_13-2}
  \caption{Different scenarios in multiple regression. (Reproduced from
    \emph{Practical Psychiatric Epidemiology}\cite{Prince:2003}, p.~250)}
  \label{fig:outline} 
\end{figure}

Several biomedical and psychological\cite{Jaffee:2009,Ryu:2009}, or
social\cite{Baron:1986} studies rely in fact on such an approach. The
interested reader is referred to e.g. Aiken \emph{\&}
West\cite{Aiken:1991}, Vittinghoff and coll.\cite{Vittinghoff:2005}
(Chapter~4), or Rothman \emph{\&} Greenland\cite{Rothman:1998}
(Chapter~2) for a thorough discussion of their implications on causal
interpretation.

According to Baron \emph{\&} Kenney\cite{Baron:1986}, a mediator must satisfy
the following conditions:
\begin{enumerate}
  \item the predictor must be significantly correlated with the
    hypothesized mediator;
  \item the predictor must be significantly correlated  with the
    outcome; 
  \item the mediator must be significantly correlated with the
    outcome;
  \item the impact of the predictor on the outcome is no longer
    significant after controlling for the mediator.
\end{enumerate}
Such mediated effect are known as indirect effect in \emph{path
analysis}\cite{Bollen:1987}.
Moderation is usually modelled as a usual linear by linear interaction
in a regression model.

\subsection{Some examples}
To give a clear picture of the aforementioned direct and indirect
effects, let's consider the following examples\cite{Ryu:2009}:
\begin{itemize}
  \item the relationship between neighborhood disadvantage (high rates
    of poverty, crime, and unemployment) and children's externalizing
    behavior is \emph{mediated} by the intervening variable of
    parent-child conflict\cite{Roosa:2005};
  \item the relationship between neighborhood disadvantage and
    children's internalizing behavior is \emph{mediated} by mother's
    perceptions of neighborhood quallity such as
    cleanliness\cite{Deng:2006};
    \item the efficacy of treatment for depression depends on
      patients' attachment insecurity, such that cognitive-behavioral
      therapy is more effective than interpersonal psychotherapy for
      patients who are higher in attachment
      avoidance\cite{McBride:2006}: the effect of therapy is thus
      \emph{moderated} by patients' attachment insecurity.
\end{itemize}
Finally, Rose\cite{Rose:1985} nicely noticed that if everyone smoked,
lung cancer would appear to be genetic disease.

\section{Mediation and interaction effects}
\subsection{Assessing Mediation effect}
In what follows, the response variable, or outcome, will be denoted as
$y$ and we deliberately avoid using the ``dedicated'' term of
\emph{dependent} variable.

Data ($n=200$) were simulated using a script provided by
Thomas~Fletcher on his
\href{www.umsl.edu/~fletchert/quant/}{homepage}. We also make use of
his \textsf{R} package \textbf{QuantPsyc} which implements methods
proposed by MacKinnon and coll.\cite{MacKinnon:2002}.

Briefly, a given sample
correlation matrix is used (with cholesky decomposition) to construct
the observed data. Figure~\ref{fig:xyz} shows how it looks like and
pairwise correlation are below in the lower diagonal part of the table
below:

\begin{center}
\begin{tabular}{r|rrr|}
\multicolumn{1}{r}{}& $x$ & $z$ & \multicolumn{1}{r}{$y$} \\ 
  \cline{2-4}
$x$ & -- & 0.28 & 0.17 \\ 
  $z$ & 0.31 & -- & 0.10 \\ 
  $y$ & 0.21 & 0.16 & -- \\ 
   \cline{2-4}
\end{tabular}
\end{center}

The partial correlation are shown in the upper-part of the correlation
matrix, where the cell $(x,y)$ refers to the correlation of $x$ and
$y$ after $z$ has been partialled out (See the R function
\verb|partial.r()| in the \textbf{psych} package).

\begin{figure}[htb]
\centering
  \includegraphics[width=.65\textwidth]{xyz}
 \caption{Joint distribution of $x$, $y$ and $z$.}\label{fig:xyz} 
\end{figure}


We use the (unadjusted) coefficient of determination ($R^2$) as a
measure of effect size and Table~\ref{tab:moderation} summarizes the
results obtained when testing the different models. Note that the
coefficient of determination can be a useful measure of
mediation\cite{Fairchild:2009}. 
As can be seen in the Table, the univariate effects of $z$ and $x$ are
significant, when considered separately, and the effect of $x$ remains
significant after accounting for the $z$ in the $y\sim x+z$ model
while that of $z$ becomes non-significant. Thus, $z$ acts as a
mediation variable. This should be distinguished from a confusion
effect which would tend to do the reverse (cancelling out the
significance of $x$ when $z$ enters the model).


\begin{table}[htbp]
\caption{Results for a simple mediation model.}
\label{tab:moderation}
\centering
\begin{tabular}{lrrr}
\cline{1-3}
Model & $R^2$ & $p$ &\\
\cline{1-3}
$y\sim x$ & 0.045 & 0.003&\\
$y\sim z$ & 0.025 & 0.025&\\
$y\sim x+z$ & 0.054 & 0.014& ($x$)\\
& & 0.161 &($z$)\\
\cline{1-3}
\end{tabular}
\end{table}

A more detailed output summary is provided by the function
\verb|proximal.med()|, see Table~\ref{tab:moderation2}.

\begin{table}[htbp]
\caption{Analysis of direct and indirect effects.}
\label{tab:moderation2}
\centering
\begin{tabular}{lrrr}
\hline
Path & Effect & SE\\
\hline
$x\rightarrow z$ & 0.301 & 0.066\\
$z\rightarrow y\mid x$ & 0.119 & 0.067\\
$x\rightarrow y$ & 0.199 & 0.063\\
$x\rightarrow y\mid z$ & 0.163 & 0.066\\
$x\rightarrow z\rightarrow y$ & 0.036 & 0.022\\
\hline
\end{tabular}
\end{table}

We can use bootstrap to get a more accurate estimate of the standard
error for the direct effect. With 1000 replicates, we get a 95\% CI of
$[0.029;0.104]$ (compared to the value 0.066 for $x\rightarrow y\mid
z$ in Table~\ref{tab:moderation2}). Here, indirect effect of $x$ on
$y$, i.e. the effect of the predictor through the mediator or
$x\rightarrow z\rightarrow y$, is about 1/5 of the direct effect, and
its SE is estimated at 0.022. Using Aroian or Goodman's
method\cite{MacKinnon:2002}, we would get similar SE estimates, namely
0.022 and 0.021.

\subsection{Assessing Moderation effect}
As previously discussed, moderation stands for the usual interaction
effect whereby the effect of a given predictor depends on the value,
or level, of another variable. Interaction can be of two kinds: We
speak of \emph{qualitative} interaction when the effect of $x$ on $y$ is
reversed depending on the level considered for $z$ (we also speak of
``crossed'' interaction), or \emph{quantitative} when $z$ positiveley or
negatively enhances the effect of $x$ on $y$.

\section{Application}
The following is inspired from a \textsf{Stata} tutorial that can be
found at
\href{http://www.ats.ucla.edu/stat/stata/faq/modmed.htm}{Stata FAQ},
but see also Vittinghohh and coll.\cite{Vittinghoff:2005}
(pp.~95--108, and
\href{http://www.aliquote.org/articles/tech/RMB/}{examples on my website}).
We will be using data from Preacher and coll.\cite{Preacher:2007},
which can be downloaded from \textsf{Stata} using the following commands:
\begin{verbatim}
. use http://www.ats.ucla.edu/stat/data/hsb2, clear
\end{verbatim}
or alternatively using the \textbf{foreign} package in \textsf{R}:
\begin{verbatim}
> require(foreign)
> hsb2 <- read.dta("hsb2.dta")
> head(hsb2)
   id female  race    ses schtyp     prog read write math science socst
1  70   male white    low public  general   57    52   41      47    57
2 121 female white middle public vocation   68    59   53      63    61
3  86   male white   high public  general   44    33   54      58    31
4 141   male white   high public vocation   63    44   47      53    56
5 172   male white middle public academic   47    52   57      53    61
6 113   male white middle public academic   44    52   51      63    61
\end{verbatim}
\verb|Science| ($y$) is the outcome and \verb|math| is the independent variable
($x$); \verb|read| is a mediator, and \verb|write| and \verb|socst|
are moderator variables. A rough PCA indicates that all five variables
are correlated and account for 68\% of the variance (with an
eigenvalue of 3.38) on the first principal component
(Figure~\ref{fig:pca}).

\begin{figure}[htb]

  \begin{minipage}[c]{0.45\linewidth}
 \includegraphics[width=\textwidth]{hsb_PCA}
\end{minipage}
%\hfill
\begin{minipage}[c]{0.45\linewidth}
\begin{footnotesize}
\begin{tabular}{l|rrrrr|}
  \multicolumn{1}{c}{}       &read& write & math &science &\multicolumn{1}{r}{socst}\\
\cline{2-6}
read   & 1.000 &0.597 &0.662  & 0.630 &0.621\\
write   &0.597 &1.000 &0.617  & 0.570 &0.605\\
math    &0.662 &0.617 &1.000  & 0.631 &0.544\\
science &0.630 &0.570 &0.631   &1.000 &0.465\\
socst   &0.621 &0.605 &0.544   &0.465 &1.000\\
\cline{2-6}
\end{tabular}
\end{footnotesize}
\end{minipage}
\caption{Correlation circle for the five variables of interest.}\label{fig:pca} 
\end{figure}

Let's first evaluate a simple model of mediation, 
\[
\fbox{\textrm{math}}\rightarrow \fbox{\textrm{read}}\rightarrow \fbox{\textrm{science}}
\]

The commands
\begin{verbatim}
hsb2.med1 <- hsb2[,c("math","read","science")]
colnames(hsb2.med1) <- c("x","m","y")
proximal.med(hsb2.med1)
\end{verbatim}
yield the results summarized in Table~\ref{tab:hsb}.

\begin{table}[htbp]
\caption{Analysis of direct and indirect effects for the \texttt{hsb2} data.}
\label{tab:hsb}
\centering
\begin{tabular}{lrrr}
\hline
Path & Effect & SE\\
\hline
$x\rightarrow z$ & 0.725 & 0.058\\
$z\rightarrow y\mid x$ & 0.365 & 0.066\\
$x\rightarrow y$ & 0.667 & 0.058\\
$x\rightarrow y\mid z$ & 0.402 & 0.073\\
$x\rightarrow z\rightarrow y$ & 0.265 & 0.053\\
\hline
\end{tabular}
\end{table}

If we test this model with \textsf{Stata} we obtain comparable
results. The syntax used is:
\begin{verbatim}
. rename science y
. rename math x  
. rename read m 
. global m=r(mean)
. global s=r(sd)
. sureg (m x)(y m x)
\end{verbatim}
which gives
\begin{footnotesize}
\begin{verbatim}
Seemingly unrelated regression
----------------------------------------------------------------------
Equation          Obs  Parms        RMSE    "R-sq"       chi2        P
----------------------------------------------------------------------
m                 200      1    7.662848    0.4386     156.26   0.0000
y                 200      2    7.133989    0.4782     183.30   0.0000
----------------------------------------------------------------------

------------------------------------------------------------------------------
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
m            |
           x |    .724807   .0579824    12.50   0.000     .6111636    .8384504
       _cons |   14.07254   3.100201     4.54   0.000     7.996255    20.14882
-------------+----------------------------------------------------------------
y            |
           m |   .3654205   .0658305     5.55   0.000     .2363951    .4944459
           x |   .4017207   .0720457     5.58   0.000     .2605138    .5429276
       _cons |    11.6155   3.031268     3.83   0.000     5.674324    17.55668
------------------------------------------------------------------------------
\end{verbatim}
\end{footnotesize}


The \textsf{Stata} tutorial provides more complicated model such that
one where the preceding indirect effect is also moderated by
\verb|math|.

\section{Conclusion}
Quoting R.~Stewart \cite{Prince:2003} (p.~251):
\begin{quotation}
\noindent
The importance of effect modification is inherently acknowledged in
the diagnostic formulation for psychiatry and other medical
specialties. In particular the division of identified potential causes
into predisposing and precipitating factors acknowledges that single
causes are usually insufficient to bring about the outcome and that
`precipitants' may require a `predisposition' in order to exert their
effects (and \emph{vice versa}). However, despite this, statistical
analyses for the majority of studies appear to be carried out entirely
to distinguish between independence and counfounding, with no
consideration of the possibility that causes might interact.
\end{quotation}



\bibliographystyle{plain}
\bibliography{mediation}

%\newpage
%\tableofcontents
\vfill

\hfill \verb|$Id: mediation.tex,v 1.0 2009/10/09 chl$|

\end{document}
