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 unobserved/.style={draw, circle, fill=gray!40},
20 legend/.style={rectangle, draw},
21 partly observed/.style 2 args={draw, fill=#2, path picture={
22 \fill[#1, sharp corners] (path picture bounding box.south west) -|
23 (path picture bounding box.north east) -- cycle;},
28 \node[observed] (y) {Y};
29 % \node[observed,above=of y, xshift=1cm] (r) {R};
30 \node[partly observed={white}{gray!40}, above=of y] (x) {X};
31 \node[observed, left=of x,xshift=-1] (w) {W};
32 \node[unobserved, above=of w, xshift=1cm] (k) {K};
34 \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){
35 \node[observed,label=right:observed] {}; \\
36 \node[unobserved,label=right:unobserved]{}; \\