\name{read.forwsim}
\alias{read.forwsim}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{ Read forward simulation output }
\description{
  This functions reads from a number of files the results of the forward simulation.
}
\usage{
read.forwsim(dir)
}
\arguments{
  \item{dir}{ Directory containing the output files from the forward simulation. }
}
\details{
  \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"}.
}
\value{ A list containing the following elements:
 \item{b0}{Vector of values of \code{"b0"}.}
 \item{b1}{Vector of values of \code{"b1"}.}
 \item{b2}{Vector of values of \code{"b2"}.}
 \item{bgrid}{Matrix containing all combinations of \code{"b0"}, \code{"b1"} and \code{"b2"} values.}
 \item{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{nreco}{Mean number of recommended treatments (1 entry for each row in \code{"bgrid"}).}
 \item{ntoreco}{Mean number of patients / number of recommended treatments (1 entry for each row in \code{"bgrid"}).}
 \item{pB}{Mean posterior probability that future trial gives significant result (1 entry for each row in \code{"bgrid"}).}
 \item{n3}{Mean sample size for future trial (1 entry for each row in \code{"bgrid"}).}
 \item{dt}{Mean number of patients tested with each treatment (1 entry for each row in \code{"bgrid"}).}
 \item{err}{Mean type I & II error rates (1 entry for each row in \code{"bgrid"}).}
 \item{mse}{Estimated mean square error (1 entry for each row in \code{"bgrid"}).}
 \item{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{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.}
}
\references{ Rossell D, Mueller P, Rosner G. Screening Designs for Drug Development. }
\author{ David Rossell. }
\seealso{ \link{forwsim} \link{optbound} }
\examples{
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


}
\keyword{ ~kwd1 }% at least one, from doc/KEYWORDS
\keyword{ ~kwd2 }% __ONLY ONE__ keyword per line
