1 \documentclass[12pt]{standalone}
4 \usepackage[utf8x]{inputenc}
6 \usepackage[T1]{fontenc}
8 \renewcommand{\rmdefault}{ugm}
9 \renewcommand{\sfdefault}{phv}
10 \usepackage[garamond]{mathdesign}
12 \usetikzlibrary{positioning, shapes, arrows, shadows}
18 observed/.style={circle, draw},
19 partly observed/.style 2 args={draw, fill=#2, path picture={
20 \fill[#1, sharp corners] (path picture bounding box.south west) -|
21 (path picture bounding box.north east) -- cycle;},
23 unobserved/.style={draw, circle, fill=gray!40}
26 \node[observed] (y) {Y};
27 \node[observed,above=of y, xshift=1cm] (r) {R};
28 \node[partly observed={white}{gray!40}, left=of r] (x) {X};
29 \node[observed, left=of x] (w) {W};
30 \node[unobserved, above=of w, xshift=1cm] (k) {K};
32 \matrix [draw, below, yshift=-0.2cm, font=\small, align=center, column sep=2\pgflinewidth, inner sep=0.6em, outer sep=0em, nodes={align=center, anchor=center}] at (current bounding box.south){
33 \node[observed,label=right:observed] {}; \\
34 \node[unobserved,label=right:unobserved]{}; \\