% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/convert_nonmem.r
\name{convert_nonmem}
\alias{convert_nonmem}
\title{Convert NONMEM model to R syntax}
\usage{
convert_nonmem(
  model,
  out,
  ext = NULL,
  mod_return = NULL,
  type_return = "mrgsolve",
  overwrite = FALSE,
  control = "file",
  verbose = TRUE
)
}
\arguments{
\item{model}{character with the model file to be read in and converted}

\item{out}{character with the name of the output file without a file extension}

\item{ext}{character with the name of the NONMEM ext file (if not provided estimates are read directly from control stream)}

\item{mod_return}{a character vector indicating which items should be returned from the model function. For more information see details}

\item{type_return}{character indicating the type of model that should be created. Currently "deSolve", "rxode2", "nonmem2rx" and "mrgsolve" are accepted}

\item{overwrite}{logical indicating if the output model should be overwritten}

\item{control}{character indicating how the model control code should be returned. Currently "file", "console", "string", "script" and "model" (only for rxode2/DeSolve) are accepted}

\item{verbose}{logical indicating if additional information is written to the console}
}
\value{
a converted file is generated and a message is returned
}
\description{
This function converts a NONMEM model to syntax useable in R simulations. Currently deSolve, rxode2 (nonmem2rx) and mrgsolve are available syntaxes to use
Additionally a code to control the simulations is created to directly test the simulations
}
\details{
For the mod_return argument, the additional variables are added to the output in case the type_return is either mrgsolve or deSolve.
}
\examples{

mod  <- system.file("example_models","PK.1CMT.ORAL.mod", package = "amp.sim")
outf <- tempfile()

convert_nonmem(mod, outf, verbose = FALSE)
readLines(paste0(outf,".cpp")) |> head(n=15) |> cat(sep="\n")

convert_nonmem(mod, outf, verbose = FALSE, type_return = "nonmem2rx") |> suppressMessages()
readLines(paste0(outf,".r")) |> head(n=15) |> cat(sep="\n")

}
\author{
Richard Hooijmaijers
}
