% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sample_par.r
\name{sample_par}
\alias{sample_par}
\title{Sample model parameters from a multivariate normal distribution}
\usage{
sample_par(
  ext,
  covmat = NULL,
  bootstrap = NULL,
  seed = NULL,
  nrepl = 10,
  inc_theta = TRUE,
  inc_eta = FALSE,
  verbose = FALSE,
  dropfixed = FALSE,
  uncert = FALSE,
  restheta = NULL
)
}
\arguments{
\item{ext}{character string with location of ext file with final model parameters}

\item{covmat}{character string with location of cov file with covariance matrix or data.frame of cov file}

\item{bootstrap}{character string with location of ext files from bootrstrap or vector with ext files from bootstrap
(relevant in case ext files should be excluded because of minimization issues)}

\item{seed}{a numeric with the seed number used in set.seed to enable reproducibility, when not provided
the seed from the global environment will be used (e.g. using \link[base:Random]{base::set.seed})}

\item{nrepl}{numeric with the number of replicates to sample}

\item{inc_theta}{logical indicating if THETAs should be added to result}

\item{inc_eta}{logical indicating if ETAs should be added to result}

\item{verbose}{logical indicating if additional information should be added to result (e.g. OMEGA/SIGMA values)}

\item{dropfixed}{logical indicating if parameters that are fixed should be dropped (can only be done in case covmat is provided)}

\item{uncert}{logical indicating if the uncertainty should be sampled}

\item{restheta}{character with the theta that describes residual error (e.g. "THETA3") in case uncertainty is sampled
this parameter will be set to the population value}
}
\value{
a dataframe with sampled values
}
\description{
This function samples model parameters from NONMEMs covariate matrix (\emph{.cov) and final parameter
estimates (}.ext). Furthermore etas can also be sampled where eta blocks are taken into account (see details)
}
\details{
In general the function can be used to sample from covariance matrix so the different parameters can be
added to a simulation dataset or model to enable uncertainty simulations. In most cases it is not necessary to
include OMEGAs or SIGMAs in these type of simulations. It can be convenient to add ETAs in the simulation dataset
to perform a simulation where no $THETA or $OMEGA information is necessary. In case inc_eta is TRUE, the ETAs
from the ext files are used and placed in a matrix to take into account covariance or
'BLOCKS'. A matrix from the ext file is constructed based on the naming of OMEGA values (e.g. OMEGA.2.1. will be
added to row 2, column 1 and column 1, row 2). The matrix is used as Sigma for the mvrnorm function with mu=0.
}
\examples{

ext <- system.file("example_models","PK.1CMT.ORAL.COV.ext", package = "amp.sim")
cov <- system.file("example_models","PK.1CMT.ORAL.COV.cov", package = "amp.sim")
sample_par(ext, inc_eta = TRUE, nrepl = 5)
sample_par(ext, cov, uncert = TRUE, nrepl = 5)

}
\seealso{
\link[MASS:mvrnorm]{MASS::mvrnorm}
}
\author{
Richard Hooijmaijers
}
