% This is a file of useful extra commands snatched from
% Michael Hills, David Clayton, Bendix Carstensen & Esa Laara.
%

% Commands to draw observation lines on follow-up diagrams
%
% Horizontal lines
%
\providecommand{\hfail}[1]{\begin{picture}(250,5)
      \put(0,0){\line(1,0){#1}}
      \put(#1,0){\circle*{5}}
   \end{picture}}

\providecommand{\hcens}[1]{\begin{picture}(250,5)
      \put(0,0){\line(1,0){#1}}
      \put(#1,0){\line(0,1){2.5}}
      \put(#1,0){\line(0,-1){2.5}}
   \end{picture}}

%
% Diagonals for Lexis diagrams
%
\providecommand{\dfail}[1]{\begin{picture}(250,250)
      \put(0,0){\line(1,1){#1}}
      \put(#1,#1){\circle*{5}}
   \end{picture}}

\providecommand{\dcens}[1]{\begin{picture}(250,250)
      \put(0,0){\line(1,1){#1}}
%      \put(#1,#1){\line(0,1){2.5}}
%      \put(#1,#1){\line(0,-1){2.5}}
% BxC Changed this to an open circle instead of a line
      \put(#1,#1){\circle{5}}
   \end{picture}}

%
% Horizontal range diagrams
%
\providecommand{\hrange}[1]{\begin{picture}(200,5)
     \put(0,0){\circle*{5}}
     \put(0,0){\line(1,0){#1}}
     \put(0,0){\line(-1,0){#1}}
   \end{picture}}

%
% Tree drawing
%
\providecommand{\Tree}[3]{\setlength{\unitlength}{#1\unitlength}\begin{picture}(0,0)
   \put(0,0){\line(3, 2){1}}
   \put(0,0){\line(3,-2){1}}
   \put(0.81, 0.54){\makebox(0,0)[br]{\footnotesize #2\ }}
   \put(0.81,-0.54){\makebox(0,0)[tr]{\footnotesize #3\ }}
\end{picture}}

\providecommand{\Wtree}[3]{\setlength{\unitlength}{#1\unitlength}\begin{picture}(0,0)
   \put(0,0){\line(1, 1){1}}
   \put(0,0){\line(1,-1){1}}
   \put(0.8,0.8){\makebox(0,0)[br]{\footnotesize #2\ }}
   \put(0.8,-0.8){\makebox(0,0)[tr]{\footnotesize #3\ }}
\end{picture}}

\providecommand{\Ntree}[3]{\setlength{\unitlength}{#1\unitlength}\begin{picture}(0,0)
   \put(0,0){\line(2, 1){1}}
   \put(0,0){\line(2,-1){1}}
   \put(0.8,0.4){\makebox(0,0)[br]{\footnotesize #2\ }}
   \put(0.8,-0.4){\makebox(0,0)[tr]{\footnotesize #3\ }}
\end{picture}}

\providecommand{\Nutree}[3]{\setlength{\unitlength}{#1\unitlength}\begin{picture}(0,0)
   \put(0,0){\line(2, 1){#1}}
   \put(0,0){\line(2,-1){#1}}
   \put(0.8,0.4){\makebox(0,0)[br]{#2\ }}
   \put(0.8,-0.4){\makebox(0,0)[tr]{#3\ }}
\end{picture}}

%
% Tree drawing
%
\providecommand{\tree}[3]{\setlength{\unitlength}{#1}\begin{picture}(0,0)
   \put(0,0){\line(3,2){1}}
   \put(0,0){\line(3,-2){1}}
   \put(0.81,0.54){\makebox(0,0)[br]{\footnotesize #2\ }}
   \put(0.81,-0.54){\makebox(0,0)[tr]{\footnotesize #3\ }}
\end{picture}}

\providecommand{\wtree}[3]{\setlength{\unitlength}{#1}\begin{picture}(0,0)
   \put(0,0){\line(1,1){1}}
   \put(0,0){\line(1,-1){1}}
   \put(0.8,0.8){\makebox(0,0)[br]{\footnotesize #2\ }}
   \put(0.8,-0.8){\makebox(0,0)[tr]{\footnotesize #3\ }}
\end{picture}}

\providecommand{\ntree}[3]{\setlength{\unitlength}{#1}\begin{picture}(0,0)
   \put(0,0){\line(2,1){1}}
   \put(0,0){\line(2,-1){1}}
   \put(0.8,0.4){\makebox(0,0)[br]{\footnotesize #2\ }}
   \put(0.8,-0.4){\makebox(0,0)[tr]{\footnotesize #3\ }}
\end{picture}}

\providecommand{\nutree}[3]{\begin{picture}(0,0)
   \put(0,0){\line(2,1){#1}}
   \put(0,0){\line(2,-1){#1}}
   \put(0.8,0.4){\makebox(0,0)[br]{#2\ }}
   \put(0.8,-0.4){\makebox(0,0)[tr]{#3\ }}
\end{picture}}

%
% Other commands
%
\providecommand{\ip}[2]{\langle #1 \vert #2 \rangle} 
\providecommand{\I}{\text{\rm gI}}
\providecommand{\prob}[0]{\text{\rm Pr}}
\providecommand{\nhy}[0]{_{\oslash}}
\providecommand{\true}[0]{_{\text{\rm \tiny T}}}
\providecommand{\hyp}[0]{_{\text{\rm \tiny H}}}
% \providecommand{\mpydiv}[0]{\stackrel{\textstyle \times}{\div}}
% Changed to slightly smaller symbols
\providecommand{\mpydiv}[0]{\stackrel{\scriptstyle\times}{\scriptstyle\div}}
\providecommand{\mie}[1]{{\it #1}}
\providecommand{\ie}{\textit{i.e.} }
\providecommand{\eg}{\textit{e.g.} }
\providecommand{\ea}{\textit{et al.} }
\providecommand{\mycircle}[0]{\circle*{5}}
\providecommand{\smcircle}[0]{\circle*{1}}
\providecommand{\corner}[0]{_{\text{\rm \tiny C}}}
\providecommand{\ind}[0]{\hspace{10pt}}
\providecommand{\gap}[0]{\\[5pt]}
\renewcommand{\S}[0]{section~}
\providecommand{\blank}[0]{$\;\,$}
\providecommand{\vone}{\vspace{1cm}}
\providecommand{\ljust}[1]{\multicolumn{1}{l}{#1}}
\providecommand{\cjust}[1]{\multicolumn{1}{c}{#1}}
\providecommand{\transpose}{^{\text{\sf T}}}
\providecommand{\histog}[5]{\rule{1mm}{#1mm}\,\rule{1mm}{#2mm}\,\rule{1mm}{#3mm}\,\rule{1mm}{#4mm}\,\rule{1mm}{#5mm}}
\providecommand{\pmiss}{P_{\mbox{\tiny miss}}}

% Below is BxCs commands inserted

% Only works with hyperref package:
\newcommand{\mailto}[1]{\href{mailto:#1}{\tt #1}}

\providecommand{\bc}{\begin{center}}
\providecommand{\ec}{\end{center}}
\providecommand{\bd}{\begin{description}}
\providecommand{\ed}{\end{description}}
\providecommand{\bi}{\begin{itemize}}
\providecommand{\ei}{\end{itemize}}
\providecommand{\bn}{\begin{equation}}
\providecommand{\en}{\end{equation}}
\providecommand{\be}{\begin{enumerate}}
\providecommand{\ee}{\end{enumerate}}
\providecommand{\bes}{\begin{eqnarray*}}
\providecommand{\ees}{\end{eqnarray*}}

\DeclareMathOperator{\Pp}{P}
\DeclareMathOperator{\pp}{p}
% \providecommand{\p}{{\mathrm p}}
\providecommand{\e}{{\mathrm e}}
\providecommand{\D}{{\mathrm D}}
\providecommand{\dif}{{\,\mathrm d}}
\providecommand{\pmat}[1]{\Pp\!\left\{#1\right\}}
\providecommand{\ptxt}[1]{\Pp\!\left\{\text{#1}\right\}}
\providecommand{\E}{\operatorname{E}}
\providecommand{\V}{\operatorname{V}}
\providecommand{\BLUP}{\operatorname{BLUP}}
\providecommand{\std}{\operatorname{std}}
\providecommand{\sd}{\operatorname{s.d.}}
\providecommand{\se}{\operatorname{s.e.}}
\providecommand{\sem}{\operatorname{s.e.m.}}
\providecommand{\Var}{\operatorname{var}}
\providecommand{\VAR}{\operatorname{var}}
\providecommand{\var}{\operatorname{var}}
\providecommand{\cov}{\operatorname{cov}}
\providecommand{\corr}{\operatorname{corr}}
\providecommand{\mean}{\operatorname{mean}}
\providecommand{\CV}{\operatorname{CV}}
\providecommand{\median}{\operatorname{median}}
\providecommand{\cv}{\operatorname{c.v.}}
\providecommand{\erf}{\operatorname{erf}}
\providecommand{\ef}{\operatorname{ef}}
\providecommand{\SSD}{\operatorname{SSD}}
\providecommand{\SPD}{\operatorname{SPD}}
\providecommand{\odds}{\operatorname{odds}}
\providecommand{\bin}{\operatorname{binom}}
\providecommand{\half}{\frac{1}{2}}
% \providecommand{\td}[0]{\stackrel{\textstyle \times}{\div}}
% Changed to slightly smaller symbols
\providecommand{\td}[0]{\stackrel{\scriptstyle \times}{\scriptstyle \div}}
\providecommand{\dt}[0]{\stackrel{\scriptstyle \div}{\scriptstyle \times}}
\providecommand{\diag}{\operatorname{diag}}
\providecommand{\det}{\operatorname{det}}
\providecommand{\dim}{\operatorname{dim}}
\providecommand{\logit}{\operatorname{logit}}
% \providecommand{\link}{\operatorname{link}}
\providecommand{\spcol}{\operatorname{span}}
\providecommand{\spn}{\operatorname{span}}
\providecommand{\CI}{\operatorname{CI}}
\providecommand{\IP}{\operatorname{IP}}
\providecommand{\OR}{\operatorname{OR}}
\providecommand{\RR}{\operatorname{RR}}
\providecommand{\ER}{\operatorname{ER}}
\providecommand{\EM}{\operatorname{EM}}
\providecommand{\EF}{\operatorname{EF}}
\providecommand{\RD}{\operatorname{RD}}
\providecommand{\AC}{\operatorname{AC}}
\providecommand{\AF}{\operatorname{AF}}
\providecommand{\PAF}{\operatorname{PAF}}
\providecommand{\AR}{\operatorname{AR}}
\providecommand{\CR}{\operatorname{CR}}
\providecommand{\PAR}{\operatorname{PAR}}
\providecommand{\EL}{\operatorname{EL}}
\providecommand{\ERL}{\operatorname{ERL}}
\providecommand{\YLL}{\operatorname{YLL}}
\providecommand{\SD}{\operatorname{SD}}
\providecommand{\SE}{\operatorname{SE}}
\providecommand{\SEM}{\operatorname{SEM}}
\providecommand{\SR}{\operatorname{SR}}
\providecommand{\SMR}{\operatorname{SMR}}
\providecommand{\RSR}{\operatorname{RSR}}
\providecommand{\CMF}{\operatorname{CMF}}
\providecommand{\pvp}{\operatorname{PV$+$}}
\providecommand{\pvn}{\operatorname{PV$-$}}
\providecommand{\R}{{\textsf{\textbf{R}}}}
\providecommand{\sas}{\textsl{\textbf{SAS}}}
\providecommand{\SAS}{\textsl{\textbf{SAS}}}
%\providecommand{\gap}[0]{\\[5pt]}
%\providecommand{\blank}[0]{$\;\,$}
% Conditional independence sign from Philip Dawid
\providecommand{\cip}{\mbox{$\perp\!\!\!\perp$}}

%%% Commands to comment out parts of the text
\providecommand{\GLEM}[1]{}
\providecommand{\FORGETIT}[1]{}
\providecommand{\OMIT}[1]{}

%%% Insert output from program in small text
%%% (requires package verbatim)
\providecommand{\insoutsmall}[1]{
 \small
 \renewcommand{\baselinestretch}{0.8}
 \verbatiminput{#1}
 \renewcommand{\baselinestretch}{1.0}
 \normalsize
}
\providecommand{\insoutfoot}[1]{
 \footnotesize
 \renewcommand{\baselinestretch}{0.8}
 \verbatiminput{#1}
 \renewcommand{\baselinestretch}{1.0}
 \normalsize
}
\providecommand{\insout}[1]{
 \scriptsize
 \renewcommand{\baselinestretch}{0.8}
 \verbatiminput{#1}
 \renewcommand{\baselinestretch}{1.0}
 \normalsize
}
\providecommand{\insouttiny}[1]{
 \tiny
 \renewcommand{\baselinestretch}{0.8}
 \verbatiminput{#1}
 \renewcommand{\baselinestretch}{1.0}
 \normalsize
}

% From Esa:
\providecommand{\T}{\text{\rm \small{T}}}
\providecommand{\id}{\operatorname{id}}
\providecommand{\Dev}{\operatorname{Dev}}
\providecommand{\Bin}{\operatorname{Bin}}
\providecommand{\probit}{\operatorname{probit}}
\providecommand{\cloglog}{\operatorname{cloglog}}

% Special commands to include output from R, Bugs and Stata

\providecommand{\Rin}[2]{
\subsection{\texttt{#1.R}}
#2

\insout{./R/#1.Rout}

}

\providecommand{\Statain}[2]{
\subsection{\texttt{#1.do}}
#2

\insout{./do/#1.log}

}

\providecommand{\Bugsin}[2]{
\subsection{\texttt{#1.bug}}
#2

\insout{./bugs/#1.bug}

}

\newlength{\wdth}
\providecommand{\fxbl}[1]{\settowidth{\wdth}{#1} \makebox[\wdth]{}}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
