I made my Hierarchical model with tikz by following code:
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{color}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage[landscape]{geometry}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows, fit}
\usetikzlibrary{positioning}
% Define block styles
\tikzstyle{response} = [cloud, circle, draw, fill=blue!20,
text width=8em, text centered, minimum height=3em]
\tikzstyle{level1} = [cloud, circle, draw, fill=green!10,
text width=7em, text centered, minimum height=2em]
\tikzstyle{level2} = [cloud, circle, draw, fill=red!10,
text width=6em, text centered, minimum height=2em]
\tikzstyle{level3} = [cloud, circle, draw, fill=yellow!10,
text width=5em, text centered, minimum height=2em]
\tikzstyle{arrow} = [thick,->,>=stealth]
\tikzstyle{a} = [rectangle, draw, minimum height=13em, minimum width=30em]
\tikzstyle{b} = [rectangle, draw, minimum height=26em, minimum width=50em]
\tikzstyle{c} = [rectangle, draw, minimum height=47em, minimum width=45em]
\author{Ehsan Masoudi}
\begin{document}
%\begin{tikzpicture}[node distance = 2cm, thick, every node/.style={scale=0.7}, auto]
%align = flush centera
\begin{tikzpicture}[thick,scale=0.7, every node/.style={transform shape}]
% Place nodes
% \node [response] (resp) {$y_{(pij)} \sim Wiener(\alpha_{(p)}, \beta, \tau_{(pij)}, \delta_{(pij)})$};
\node [response] (resp) {$y_{(pij)}$};
%%level1
\node [level1, above = 1.5cm of resp] (alpha) {$\alpha_{(p)} \sim N(\mu_{\alpha}, \sigma^2_{\alpha})$};
\node [level1, left = .7cm of resp] (tau) {$\tau_{(pij)} \sim N(\theta_{(p)}, \chi_{(p)})$};
\node [level1, right = .7cm of resp] (delta) {$\delta_{(pij)} \sim N(\nu_{(pi)}, \eta_{(p)})$};
%%level2
\node [level2, above left = 1.5cm and -.4cm of alpha] (mu-alpha) {$\mu_\alpha \sim U(.01, 3)$};
\node [level2, above right = 1.5cm and -.4cm of alpha] (sigma-alpha) {$\sigma_\alpha \sim U(.0001, 2)$};
\node [level2, above left = 3cm and 0.5cm of tau] (theta) {$\theta_{(p)} \sim N(\mu_\theta, \sigma_\theta)$};
\node [level2, below = 5.5cm of tau] (chi) {$\chi_{(p)} \sim N(\mu_\chi, \sigma_\chi)$};
\node [level2, above right = 3cm and .4cm of delta] (eta) {$\eta_{(p)} \sim N(\mu_\eta, \sigma_\eta)$};
\node [level2, below = 1cm of delta] (nu) {$\nu_{(pi)}\sim N(\mu_{\nu(i)}, \sigma_{\nu(i)})$};
\node [level3, above left = 1.5cm and -.4cm of theta] (mu-theta) {$\mu_\theta \sim U(.01, 1)$};
\node [level3, above right = 1.5cm and -.4cm of theta] (sigma-theta) {$\sigma_\theta \sim U(.0001, .25)$};
\node [level3, above right = .7cm and 4.2cm of nu] (mu-nu) {$\mu_{\nu(i)} \sim U(-5, 5)$};
\node [level3, right = 4cm of nu] (sigma-nu) {$\sigma_{\nu(i)}\sim U(.0001, 3)$};
\node [level3, above left = 1.5cm and -.4cm of eta] (mu-eta) {$\mu_\eta = 3.5$};
\node [level3, above right = 1.5cm and -.4cm of eta] (sigma-eta) {$\sigma_\eta = 3.5$};
\node [level3, below left = 1.5cm and -.4cm of chi] (mu-chi) {$\mu_\chi = .35$};
\node [level3, below right = 1.5cm and -.4cm of chi] (sigma-chi) {$\sigma_\chi = .125$};
%\node [above right =0.75cm and 0cm of theta] {CGPA} edge (student);
%level1
\draw [arrow] (mu-theta) -- (theta);
\draw [arrow] (sigma-theta) -- (theta);
\draw [arrow] (mu-alpha) -- (alpha);
\draw [arrow] (sigma-alpha) -- (alpha);
\draw [thick, dashed, ->] (mu-eta) -- (eta);
\draw [thick, dashed, ->] (sigma-eta) -- (eta);
\draw [arrow] (mu-nu) -- (nu);
\draw [arrow] (sigma-nu) -- (nu);
\draw [thick, dashed, ->] (mu-chi) -- (chi);
\draw [thick, dashed, ->](sigma-chi) -- (chi);
%level2
\draw [arrow] (chi) -- (tau);
\draw [arrow] (theta) -- (tau);
\draw [arrow] (eta) -- (delta);
\draw [arrow] (nu) -- (delta);
%level2
\draw [arrow] (chi) -- (tau);
\draw [arrow] (theta) -- (tau);
\draw [arrow] (eta) -- (delta);
\draw [arrow] (nu) -- (delta);
%%path
\draw [arrow] (alpha) -- (resp);
\draw [arrow] (tau) -- (resp);
\draw [arrow] (delta) -- (resp);
\node[a,fit=(resp) (tau) (delta)] (container) {};
\node[b,fit=(resp) (tau) (delta)(nu)(mu-nu)(sigma-nu)] (container) {};
\node[c,fit=(resp) (tau) (delta)(nu)(chi)(theta)(alpha)(eta)] (container) {};
\end{tikzpicture}
\end{document}
Now, I would like to add index p = 1,...P, i = 1,...I and j = 1,...J for each plate (red index in the figure is drawn by paint!)
any help would be appreciated.
P.S.: in addition how can I bold the text in all nodes my one syntax? or any syntax that make them more obvious. For example, arranging all of the prior distributions in a column next to the model.
font=\bfseries
to the options you pass totikzpicture
?labels
inside nodes but you can add new nodes where you need.\node[above=3mm of container.south] {p index};
could serve you to label third container. Previous syntax is valid if you introduce it after everycontainer
if you want to add all labels after allfit
nodes, change their names accordingly.