[Tex/LaTex] Displaying mediator analysis with LaTeX (TikZ-pfg maybe?)

graphicsstatisticstikz-pgf

I want to "draw" a mediator analysis with LaTeX, e.g. with TikZ. Unfortunately, I did not find any template for such a graphic; plus, I am lacking of skill to do it on my own (but very willing to learn!). Thus, I cannot offer a MWE! 🙁

The graphic shown below is made with Microsoft PP and displays some random variable names and values which should be replaceable with other variable names and values…

Example

Can someone reproduce such a mediator model with TikZ?
I also wonder if the font in the graphic will be the same like my document settings?

Best Answer

I won't provide explanations but suggest you to read pgfmanual. There are nice tutorials there as commented by darthbith. What you want can be easily done.

\documentclass[tikz,border=4]{standalone}
\usepackage{siunitx}
\usetikzlibrary{positioning}
\tikzset{mynode/.style={draw,text width=1in,align=center}
}
\begin{document}
  \begin{tikzpicture}
    \node[mynode] (m){Mediator};
    \node[mynode,below left=of m](a) {Variable A};
    \node[mynode,below right=of m](b) {Variable B};
    \draw[-latex] (a.north) -- node[auto,font=\footnotesize] {$b=-0.56$, $p=0.04$} (m.west);
    \draw[-latex] (m.east) -- node[auto,font=\footnotesize] {$b=-0.44$, $p<0.001$} (b.north);
    \draw[-latex] (a.east) --
            node[below=3mm,font=\footnotesize,align=center] {Direct effect, $b=0.55$,
                 $p=0.03$ \\ Indirect effect, $b=0.16$, \SI{90}{\percent} CI [ 0.04,0.36]}
                 (b.west);
  \end{tikzpicture}
\end{document}

enter image description here

Related Question