% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/make_nmsimmodel.r
\name{make_nmsimmodel}
\alias{make_nmsimmodel}
\title{Create a simulation model from original model}
\usage{
make_nmsimmodel(omod, smod, data, subprobs = 1, table = NULL, sigma_ext = NULL)
}
\arguments{
\item{omod}{character string for the original model}

\item{smod}{character string for the simulation model (for writing the model to disk)}

\item{data}{character string for the input dataset for the simulation}

\item{subprobs}{numeric indicating the number of subproblems in simulation model}

\item{table}{character of length 1 with the items for the dollar table block (if null it will use items in input dataset)}

\item{sigma_ext}{character with the name of the ext file which includes the sigma value (in case residual error is coded in the dollar sigma block)}
}
\value{
a simulation model (file) is created
}
\description{
This function creates a simulation model from an original NONMEM model where dollar blocks are replaced and/or
commented based on input file and other simulation functions within package
}
\details{
The function will adapt an original model in such a way that it can be used directly for simulations
the assumptions are that an input dataset is created using \link{sample_par} and \link{simdata}.
This means that all THETA and ETA values are available in the simulation dataset as respectively STHETAN and SETAN (simulated THETA/ETA n).
Furthermore it is assumed that the input dataset is a csv file.
The function will first comment all applicable dollar blocks. Then a OMEGA is added with 0 FIX and the INPUT, DATA and
TABLE blocks are appended with information based on the input dataset. Finally all THETAs and ETAs are replaced with
the items in the dataset and the simulation model is written to  disk.
}
\examples{

nmmod   <- system.file("example_models","PK.1CMT.ORAL.mod", package = "amp.sim")
dat     <- simdata(0:24, dosetime = 0, doseheight = 10, addl = 2, ii = 24, 
                   numid = 50, STHETA1= 1, STHETA2 = 2, STHETA3 = 1,
                   SETA1 = 0, SETA2 = 0)
tmp_out <- tempfile(fileext = ".csv")
mod_out <- tempfile(fileext = ".mod")

write.csv(dat,file=tmp_out, na=".", quote=FALSE, row.names = FALSE)
make_nmsimmodel(nmmod, mod_out, data=tmp_out)
readLines(mod_out) |> head(n=15) |> cat(sep="\n")

}
\author{
Richard Hooijmaijers
}
