我想用 LaTeX(例如 TikZ)“绘制”一个中介分析。不幸的是,我没有找到这种图形的任何模板;而且,我缺乏独自完成这项任务的技能(但非常愿意学习!)。因此,我无法提供 MWE!:(
下面显示的图形是用 Microsoft PP 制作的,显示了一些随机变量名称和值,这些变量名称和值应该可以用其他变量名称和值替换......
有人可以用 TikZ 重现这样的中介模型吗?我还想知道图形中的字体是否与我的文档设置相同?
答案1
我不会提供解释,但建议你阅读 pgfmanual。那里有很好的教程,正如 darthbith 所评论的。你想要的东西可以轻松完成。
\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}
答案2
以下是针对两位调解员的说明:
\documentclass[tikz,border=4]{standalone}
\usepackage{siunitx}
\usetikzlibrary{positioning}
\tikzset{mynode/.style={draw,text width=1in,align=center}
}
\begin{document}
\begin{tikzpicture}
\node[mynode] (m1){M1};
\node[mynode, right=3cm of m1] (m2){M2}; % Manual adjustment of sep
\node[mynode,below left=of m1](a){X};
\node[mynode,below right=of m2](b){Y};
\draw[-latex] (a.north) -- node[auto,font=\footnotesize] {A}(m1.west);
\draw[-latex] (m1.east) -- node[auto,font=\footnotesize] {B} (m2.west);
\draw[-latex] (m2.east) -- node[auto,font=\footnotesize] {C} (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}
另一个适用于两个平行的单个介体:
\documentclass[tikz,border=4]{standalone}
\usepackage{siunitx}
\usetikzlibrary{positioning}
\tikzset{mynode/.style={draw,text width=1in,align=center}
}
\begin{document}
\begin{tikzpicture}
\node[mynode] (m1){Mediator 1};
\node[mynode,below left=of m1](a) {Variable A};
\node[mynode,below right=of m1](b) {Variable B};
\node[mynode,below = 2.5cm of m1] (m2){Mediator 2};
\draw[-latex] (a.north) -- node[auto,font=\footnotesize] {A} (m1.west);
\draw[-latex] (m1.east) -- node[auto,font=\footnotesize] {B} (b.north);
\draw[-latex] (a.east) --
node[below,font=\footnotesize,align=center] {C}
(b.west);
\draw[-latex] (a.south) -- node[below,font=\footnotesize] {D} (m2.west);
\draw[-latex] (m2.east) -- node[below,font=\footnotesize] {E} (b.south);
\end{tikzpicture}
\end{document}