\HeaderA{read.forwsim}{Read forward simulation output}{read.forwsim}
\keyword{~kwd1}{read.forwsim}
\keyword{~kwd2}{read.forwsim}
\begin{Description}\relax
This functions reads from a number of files the results of the forward simulation.
\end{Description}
\begin{Usage}
\begin{verbatim}
read.forwsim(dir)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{dir}] Directory containing the output files from the forward simulation. 
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
\code{"read.forwsim"} looks for text files with very specific names. Failure to find them will cause an error.
The required files are \code{"b0.sim","b1.sim","b2.sim","U.sim","nreco.sim","ntoreco.sim","pB.sim","n3.sim","dt.sim"}
\code{,"errI.sim","errII.sim","mse.sim","traj.dsg","term.sim"}.
\end{Details}
\begin{Value}
A list containing the following elements:
\begin{ldescription}
\item[\code{b0}] Vector of values of \code{"b0"}.
\item[\code{b1}] Vector of values of \code{"b1"}.
\item[\code{b2}] Vector of values of \code{"b2"}.
\item[\code{bgrid}] Matrix containing all combinations of \code{"b0"}, \code{"b1"} and \code{"b2"} values.
\item[\code{u}] Mean utility (1 entry for each row in \code{"bgrid"}). Set to minimum value for those \code{"b0"},\code{"b1"},\code{"b2"} not evaluated in the simulation.
\item[\code{nreco}] Mean number of recommended treatments (1 entry for each row in \code{"bgrid"}).
\item[\code{ntoreco}] Mean number of patients / number of recommended treatments (1 entry for each row in \code{"bgrid"}).
\item[\code{pB}] Mean posterior probability that future trial gives significant result (1 entry for each row in \code{"bgrid"}).
\item[\code{n3}] Mean sample size for future trial (1 entry for each row in \code{"bgrid"}).
\item[\code{dt}] Mean number of patients tested with each treatment (1 entry for each row in \code{"bgrid"}).
\item[\code{err}] Mean type I \& II error rates (1 entry for each row in \code{"bgrid"}).
\item[\code{mse}] Estimated mean square error (1 entry for each row in \code{"bgrid"}).
\item[\code{traj}] Some sample trajectories saved for the point specified by the argument \code{uhat.bsave} in \code{forwsim}. If the file is empty this component will contain an error message.
\item[\code{term}] Terminal decisions and posterior moments for sample trajectories saved for the point specified by the argument \code{uhat.bsave} in \code{forwsim}. If the file is empty this component will contain an error message.
\end{ldescription}
\end{Value}
\begin{Author}\relax
David Rossell.
\end{Author}
\begin{References}\relax
Rossell D, Mueller P, Rosner G. Screening Designs for Drug Development.
\end{References}
\begin{SeeAlso}\relax
\LinkA{forwsim}{forwsim} \LinkA{optbound}{optbound}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
dir <- 'C:/R/R-2.2.1/library/forwsim/data'                              #read forward simulation output
sim1 <- read.forwsim(dir)

opt1 <- optbound(sim1,errImax=1,errIImax=1,util='u',smooth=FALSE)       #unconstrained optimization

\end{ExampleCode}
\end{Examples}

