\documentclass[../Main.tex]{subfiles}

\begin{document}
%\subsection{Data Exploration} %TODO: fill this out later.
%look at trial 
\subsection{Model Fitting}
In this section we examine the results from fitting the econometric model using
mc-stan (\cite{mc-stan}) through the rstan (\cite{rstan}) interface.

%describe 
The model was based on the hierarchal logistic regression model 
presented in the Stan Users Guide (\cite{mc-stan}), 
and was run with 2,500 warmup iterations and
2,500 sampling iterations in six chains.
There were various issues, including 160 divergent transitions and the R-hat 
measure was 1.49. 
Overall these suggest that the econometric model is incorrect as 
written or requires reparameterization.
%TODO: and info about how I learned about these diagnostics


% \subsubsection{Diagnostics}
% %Examine trank plots
% To identify which parameters were problematic, I first looked at trace rank 
% histograms.
% Under idea circumstances, each line (representing a chain) should exchange 
% places with the other lines frequently.
% In both \cref{fig:mu_trank} and \cref{fig:sigma_trank}, most parameters seem
% to mix well but there are a couple of exceptions.
% This warrants further investigation.
%
% \begin{figure}[H]
%     \includegraphics[width=\textwidth]{../assets/img/mu_trank.png}
%     \caption{Trace Rank Histogram: Mu values}
% 	\label{fig:mu_trank}
% \end{figure}
%
% \begin{figure}[H]
%     \includegraphics[width=\textwidth]{../assets/img/sigma_trank.png}
%     \caption{Trace Rank Histogram: Sigma values}
% 	\label{fig:sigma_trank}
% \end{figure}
%
% %Take a look at batman and points for mu
% In the case of the Mu values, a parallel coordinates plot 
% doesn't seem to indicate any parameters as likely candidates
% for causing the issues with divergent transitions.
% \begin{figure}[H]
%     \includegraphics[width=\textwidth]{../assets/img/mu_batman.png}
%     \caption{Parallel Coordinate Plot: Mu values}
% 	\label{fig:mu_batman}
% \end{figure}
% Note that at each parameter, there is some level of dispersion between 
% values that diverged.
%
% On the other hand, in the parallel coordinates plot for sigma values,
% it appears that most divergent transitions occur with values of 
% sigma[1], sigma[3], sigma[6], and sigma[7] close to zero.
% \begin{figure}[H]
%     \includegraphics[width=\textwidth]{../assets/img/sigma_batman.png}
%     \caption{Parallel Coordinate Plot: Sigma values}
% 	\label{fig:sigma_batman}
% \end{figure}
% Overall this suggests that there is an issue with the specification
% of the covariance structures of the hyperparameters.
%
% Additional evidence that the covariance structure is incorrect comes from 
% plotting pairs of parameter values and examining the chains with divergent
% transitions.
%
% \begin{figure}[H]
%     \includegraphics[width=\textwidth]{../assets/img/sigma_pairs_5-9.png}
% 	\caption{Parameter Pairs plots: Sigma[5] through Sigma[9]}
% 	\label{fig:sigma_pairs_5-9.png}
% \end{figure}
% From this we can see that divergent pairs are highly correlated with the cases
% where sigma[6] or sigma[7] are equal to zero.
% This has an impact on the shape of both of those estimated parameters, causing
% both to be bimodal.


\subsection{Interpretation}

The key results so far are related to the distribution of differences in $p$.

In figure \ref{fig:pred_dist_dif_delay} we see that there while most trials do not see any increased risk 
from a delay in closing enrollment, there is a small group that does experience this.

\begin{figure}[H]
    \includegraphics[width=\textwidth]{../assets/img/current/pred_dist_diff-delay}
	\caption{}
	\label{fig:pred_dist_diff_delay}
\end{figure}

Figure \ref{fig:pred_dist_dif_delay2} shows how this varies across disease categories
\begin{figure}[H]
    \includegraphics[width=\textwidth]{../assets/img/current/pred_dist_diff-delay-group}
	\caption{}
	\label{fig:pred_dist_dif_delay2}
\end{figure}

We can also examine the direct effect from adding a single generic competitior drug.

\begin{figure}[H]
    \includegraphics[width=\textwidth]{../assets/img/current/pred_dist_diff-generic}
	\caption{}
	\label{fig:pred_dist_diff_generic}
\end{figure}

Figure \ref{fig:pred_dist_dif_generic2} shows how this varies across disease categories
\begin{figure}[H]
    \includegraphics[width=\textwidth]{../assets/img/current/pred_dist_diff-generic-group}
	\caption{}
	\label{fig:pred_dist_dif_generic2}
\end{figure}



\end{document}
