Title: Pharmacometric Modeling
Version: 3.1.0
Description: Facilitate Pharmacokinetic (PK) and Pharmacodynamic (PD) modeling and simulation with powerful tools for Nonlinear Mixed-Effects (NLME) modeling. The package provides access to the same advanced Maximum Likelihood algorithms used by the NLME-Engine in the Phoenix platform. These tools support a range of analyses, from parametric methods to individual and pooled data, and support integrated use within the Pirana pharmacometric workbench <doi:10.1002/psp4.70067>. Execution is supported both locally or on remote machines.
Depends: R (≥ 4.0)
License: LGPL-3
URL: https://certara.github.io/R-RsNLME/
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.3.2
Suggests: rlang, knitr, rmarkdown, testthat, magrittr
Imports: xml2, assertthat, Certara.NLME8, data.table, jsonlite, methods, utils, ssh
Collate: 'BootstrapParams.R' 'NlmeParallelMethod.R' 'NlmeUserAuthentication.R' 'NlmeParallelHost.R' 'SimpleNlmeJob.R' 'BootNlmeJob.R' 'CovariateEffectModel.R' 'GenerateControlfile.R' 'GenerateParamsfile.R' 'NlmeColumnMapping.r' 'NlmeCovariateParameter.r' 'NlmeDataset.r' 'NlmeDoseMapping.R' 'NlmeEmaxParameters.R' 'NlmeIndirectParameters.R' 'NlmeModelAbsorption.R' 'NlmeModelParameterization.R' 'NlmeModelType.R' 'NlmeParamsMapping.R' 'NlmePkParameters.R' 'NlmePmlModelInfo.R' 'NlmeRandParamsMapping.R' 'NlmeRandomEffectBlock.r' 'NlmeRemoteExecutor.R' 'NlmeScenario.R' 'NlmeTableDef.R' 'SortColumns.R' 'ProfileParameters.R' 'ProfileNlmeJob.R' 'ProfileVar.R' 'error_model.r' 'pml_model.r' 'RandomEffectsMethods.R' 'ShotgunNlmeJob.R' 'SortByNlmeJob.R' 'StepwiseParams.R' 'StepwiseNlmeJob.R' 'acceptAllEffects.R' 'addInfusion.R' 'addLabel.R' 'addTablesToColumnMapping.R' 'add_input_dosingCycles.R' 'bootstrap.r' 'built_in_models.r' 'checkHostParams.R' 'colMapping.R' 'copyModel.R' 'covariateModel.R' 'covariateNames.R' 'createInitialMapping.R' 'create_model_from_metamodel.R' 'create_model_info.R' 'data.r' 'dosing.r' 'editModel.R' 'emaxmodel.R' 'engine_params.r' 'extract_mmdl.R' 'fitmodel.R' 'fitmodelHelperFunctions.R' 'fixedEffect.R' 'generateCovarSearchArgsFile.R' 'getThetas.R' 'get_omega_omegaSE.R' 'globals.R' 'hostParams.R' 'job.r' 'linearmodel.R' 'log_Execution.R' 'map_covariates.R' 'map_dosepoints.R' 'modelVariableNames.R' 'observation.r' 'obtain_NLMELicense.R' 'parameterNames.R' 'parseControlFile.R' 'parsePMLColMap.R' 'parse_mmdl.R' 'pkemaxmodel.R' 'pkindirectmodel.R' 'pklinearmodel.R' 'pkmodel.R' 'profile_estimation.r' 'randomEffect.R' 'readInitialEstimatesParams.R' 'run_metamodel.R' 'saveModel.R' 'saveUpdatedMetamodel.R' 'secondary_variable.r' 'shotgunSearch.R' 'simParams.R' 'sortfit.R' 'stepwiseSearch.R' 'structural_param.r' 'tableParams.R' 'update_PMLwithThetas.R' 'vpc.r' 'writeColumnMapping.R' 'writeDefaultFiles.R'
NeedsCompilation: no
Packaged: 2025-08-20 15:11:59 UTC; jcraig
Author: James Craig [aut, cre], Michael Tomashevskiy [aut], Vitalii Nazarov [aut], Shuhua Hu [ctb], Soltanshahi Fred [aut], Certara USA, Inc. [cph, fnd]
Maintainer: James Craig <james.craig@certara.com>
Repository: CRAN
Date/Publication: 2025-08-22 06:40:13 UTC

Represents parameters for a bootstrap run

Description

Class initializer for BootstrapParams that represents parameters for a bootstrap run.

Slots

numReplicates

Number of bootstrap replicates to run

initialEstimates

Get model final estimates to run bootstrap (T|F)

numRetries

Number of times to retry a failed replicated

randomNumSeed

Seed for random number generator

confidenceLevel

Confidence level

stratifyColumns

What columns to stratify on(comma separated)

Examples

# same object as BootstrapParams()
boot <- BootstrapParams(
  numReplicates = 100,
  initialEstimates = FALSE,
  numRetries = 2,
  randomNumSeed = 1234,
  confidenceLevel = 95
)


NLME covariate effects model object class

Description

Class represents an NLME covariate effects model

Slots

numCovariates

Number of covariate effects

covariateList

Comma separated list of covariate effects names

scenarioNames

Comma separated list of scenario names

isDefault

Comma separated list of flags

degreesOfFreedom

Comma separated list of degrees of freedom

Examples

CovariateEffectModel(numCovariates = 2,
                     covariateList = "V-Age,Cl-BW",
                     scenarioNames = "S,S",
                     isDefault = "1,1",
                     degreesOfFreedom = "1,1")

Creates an extra dose parameter

Description

Creates an extra dose parameter

Arguments

type

ValueType|ColumnType

value

Value of dosing parameter

column

Name of column containing dose information


Defines an extra dose point

Description

Defines an extra dose point

Slots

name

Dose point name

type

Character; Options are "Bolus" or "Infusion"

amount

Optional; Character specifying corresponding column in data or numeric specifying dose amount

rate

Optional; Character specifying corresponding column in data or numeric specifying dose rate

deltaTime

Optional; Character specifying corresponding column in data or numeric specifying delta time

isSecondDose

Use second dose point on compartment?

data

Optional data frame. Must specify data if supplying column as character value to amount, rate, deltaTime arguments


Class represents map between a model variable and a dataset column

Description

Class represents map between a model variable and a dataset column

Arguments

variableName

Model variable name

columnName

Corresponding column name in the dataset

variableType

Model variable type


Class represents mapping list between model variables and dataset columns

Description

Class represents mapping list between model variables and dataset columns


Class represents an NLME Covariate parameter

Description

Class represents an NLME Covariate parameter

Arguments

name

Name of covariate

value

Covariate value


NlmeCovariateParameter

Description

Class represents an NLME Covariate parameter

Arguments

name

Name of covariate parameter

type

Type of covariate parameter: Continuous|Category|Occasion

direction

Curve fitting method: Forward|Interpolate|Backward

isDiagonal

Is the structure diagonal (TRUE)| or box (FALSE)

centerValue

Covariate centering value

isPositive

Are the covariate values all positive

continuousType

Type of value to use for the centering value: CovarNumber|CovarMean|CovarMedian

covarEffList

List of covariate effects

covarItems

List of covariate items


NLME dataset object

Description

Class represents an NLME dataset object

Arguments

dataFile

Subject datafile

colDefFile

Datafile to model mapping file

modelFile

PML model file

estimatesDefFile

Initial estimates mapping file

estimatesDataFile

Initial estimates values

doseDefFile

Dose column definition file

doseDataFile

Dose datafile

ranEffectDefFile

Random effects column definition file

ranEffectDataFile

Random effects data file

predoutFilename

Name of predcheck output file

phoenixSourceDir

Directory containing phoenix generated files

workingDir

Directory containing datafiles(default cwd)

Examples

dataset <- NlmeDataset(workingDir)

Class represents mapping list between model variables and dose columns

Description

Class represents mapping list between model variables and dose columns


Class represents an NLME/PML Emax model parameters

Description

Class represents an NLME/PML Emax model parameters

Arguments

checkBaseline

Model has a baseline response

checkFractional

Model is fractional

checkInhibitory

Model is inhibitory

checkSigmoid

Model is sigmoidal


Create a new NlmeEngineExtraParams object

Description

This function creates a new instance of the NlmeEngineExtraParams class

Usage

NlmeEngineExtraParams(...)

Arguments

...

Named arguments to override the default values.

Value

An object of class NlmeEngineExtraParams.


NlmeEngineExtraParams : Defines all engine parameters for NLME models Wrapped up by engineParams function.

Description

NlmeEngineExtraParams : Defines all engine parameters for NLME models Wrapped up by engineParams function.

Slots

isPopulation

logical; TRUE if the model is a population model, FALSE for an individual model.

sort

character; String to pass sorting options to the NLME engine. Typically " -sort " to enable sorting or "" to disable it.

csv

character; String to control CSV input options. Typically " -csv " to strict the input data to comma-separated-values. Use "" to disable it (NLME will try to guess the input format).

method

numeric; Integer code specifying the estimation method.

  • 1: QRPEM

  • 2: IT2S-EM

  • 3: FOCE-LB

  • 4: FO

  • 5: FOCE-ELS/LAPLACIAN (see below for choice between FOCE-ELS and LAPLACIAN)

  • 6: NAIVE-POOLED

The choice between FOCE-ELS and LAPLACIAN (when method is 5) depends on the xfocehess slot: xfocehess = 1 selects FOCE-ELS, and xfocehess = 0 selects LAPLACIAN.

numIterations

numeric; The maximum number of iterations allowed for the estimation algorithm. Values must be non-negative integers.

odeToUse

numeric; Integer code specifying the ODE solver to be used. Possible values are:

  • 1: LSODE with numerical Jacobian

  • 2: LSODE with analytical Jacobian

  • 3: Runge-Kutta

  • 4: LSODA with numerical Jacobian

  • 5: LSODA with analytical Jacobian

  • 6: Matrix Exponent

  • 7: DOPRI5

rtol

numeric; Specifies the relative tolerance for the ODE solver.

atol

numeric; Specifies the absolute tolerance for the ODE solver.

nmxstep

numeric; Specifies the maximum number of steps allowed for the ODE solver.

anagrad

numeric; Flag controlling the differentiation method used during the optimization of random effects (etas). 0 uses a finite difference approach, and 1 uses automatic differentiation where possible.

xnp

numeric; Controls the use of non-parametric (NP) optimization.

  • 0: No NP optimization.

  • 1: NONMEM-style NP optimization using posthoc estimates as support points.

  • >1: Evolutionary NP algorithm with xnp generations.

xnorderagq

numeric; Specifies the number of quadrature points per dimension for Adaptive Gaussian Quadrature (AGQ). Only applicable when method is FOCE-ELS or LAPLACIAN.

  • 1: Standard FOCE-ELS/LAPLACIAN computation (no AGQ).

  • >1: AGQ is performed. The total number of quadrature points used is (number of ETAs)^xnorderagq.

xfocehess

numeric; Determines the method for calculating the Hessian matrix when using FOCE methods.

  • 0: Use numerical second derivatives.

  • 1: Use the FOCE approximation.

Applicable only when method is FOCE-ELS or LAPLACIAN.

xstderr

numeric; Specifies the method for standard error estimation.

  • 0: No standard error estimation.

  • 1: Central difference method.

  • 2: Forward difference method.

sand

character; String to request sandwich standard error calculation. Typically " -sand " or "".

fisher

character; String to request Fisher score standard error calculation. Typically " -fscore " or "".

autodetect

character; String to request auto-detection of standard error method. Typically " -AutoSE " or "".

xlandig

numeric; Specifies the optimization accuracy (NDIGIT) for the outer loop (thetas and sigmas) when using FOCE-ELS or LAPLACIAN methods.

xlatol

numeric; Specifies the relative step size used for numerical computation of the Hessian matrix (second derivatives) during standard error calculation.

xblndig

numeric; Specifies the optimization accuracy (NDIGIT) for the inner loop (optimization of etas). Also applies to the single optimization loop in the NAIVE-POOLED method.

xbltol

numeric; Specifies the relative step size for numerical differentiation during model linearization.

gradTolOuter

Numeric maximum gradient tolerance in the outer (Theta/Omega/Sigma) optimization loop. Applicable to FOCE-ELS and LAPLACIAN methods.

stepTolOuter

Numeric maximum step tolerance in the outer (Theta/Omega/Sigma) optimization loop. Applicable to FOCE-ELS and LAPLACIAN methods.

gradTolInner

Numeric maximum gradient tolerance in the inner (Eta) optimization loop. Applicable to FOCE-ELS and LAPLACIAN methods.

stepTolInner

Numeric maximum step tolerance in the inner (Eta) optimization loop. Applicable to FOCE-ELS and LAPLACIAN methods.

refDeltaLagl

Numeric LL Delta tolerance value used during Theta/Omega/Sigma optimization. Applicable to FOCE-ELS and LAPLACIAN methods.

isPCWRES

numeric; Flag indicating if Population Conditional Weighted Residuals (PCWRES) should be computed. A value of 1 indicates computation, while 0 indicates no computation. Only applicable to population models.

xpcwresnrep

numeric; Stores the number of simulation replicates used for PCWRES computation. Applicable only when isPCWRES is 1.

xisample

numeric; Specifies the number of sample points used in the QRPEM algorithm. Only applicable when method is QRPEM.

xmapassist

numeric; Controls the use of MAP assistance in the QRPEM algorithm.

  • 0: No MAP assistance.

  • >0: The inner ETAs optimization loop is used in the QRPEM outer optimization loop with a periodicity equal to the value of xmapassist.

Only applicable when method is QRPEM.

xmapnp

numeric; Specifies the number of iterations for a preliminary Naive-Pooled optimization run before the main estimation. Applicable when the method is not NAIVE-POOLED.

ximpsampdof

numeric; Controls the importance sampling distribution used in the QRPEM algorithm. Only applicable when method is QRPEM.

  • 0: Multivariate Normal distribution.

  • 1: Multivariate Double Exponential (Laplace) distribution.

  • 2: Direct sampling from the prior.

  • 3-30: Multivariate T distribution with degrees of freedom equal to the value of ximpsampdof.

  • -2: Mixture-2 distribution.

  • -3: Mixture-3 distribution.

xmcpem

numeric; Controls the sampling method used in the QRPEM algorithm.

  • 0: Quasi-Random sampling.

  • 1: Monte-Carlo sampling.

Only applicable when method is QRPEM.

xpemrunall

numeric; Set to 1 to execute all requested iterations specified in numIterations. Only applicable to population models with method = "QRPEM".

xsirsamp

numeric; Specifies the number of samples per eta per subject used in the Sampling Importance Resampling (SIR) algorithm within QRPEM. Only applicable when method is QRPEM.

xburnin

numeric; Specifies the number of burn-in iterations in the QRPEM algorithm. During burn-in, omegas can be frozen (see xnonomegaburn). Only applicable when method is QRPEM.

xnonomegaburn

numeric; Controls whether omegas are frozen during the burn-in phase of the QRPEM algorithm.

  • 0: burn-in with frozen omegas is off.

  • 1: burn-in with frozen omegas is on.

Only applicable when method is QRPEM. See also xburnin.

xaccratio

numeric; Specifies the acceptance ratio used in the QRPEM algorithm for scaling the covariance matrix. Only applicable when method is QRPEM. Only applicable to population models with method = "QRPEM".

xscramble

numeric; Specifies the scrambling method for quasi-random number generation in the QRPEM algorithm.

  • 0: No scrambling.

  • 1: Owen-type scrambling.

  • 2: Faure-Tezuka scrambling.

Only applicable when method is QRPEM.

emTolType

Numeric specifying QRPEM convergence check type:

0

Default (no rollout, LL & Thetas)

1

LL & Params with rollout

2

LL with rollout

3

Params with rollout

Only applicable when method is QRPEM.

emConvLen

Numeric specifying the number of iterations to check for convergence. Only applicable when method is QRPEM.

emConvCritVal

Numeric specifying the convergence critical value. Only applicable when method is QRPEM.

pardern

numeric; Specifies the number of time steps used for outputting partial derivatives of observed variables with respect to parameters. Only applicable to individual models.

parderd

numeric; Specifies the step size for numerical calculation of partial derivatives of observed variables with respect to parameters. Only applicable to individual models.

logtran

numeric; Engine flag controlling log-transformation behavior for single LogAdditive error model.

See Also

[engineParams()]

Examples

param <- NlmeEngineExtraParams(
  method = 3,
  numIterations = 1000
)
param <- NlmeEngineExtraParams(
  method = 1,
  numIterations = 300
)
param <- NlmeEngineExtraParams(
  method = 1,
  numIterations = 300,
  isPopulation = TRUE,
  odeToUse = 2
)

Class represents an NLME/PML error model

Description

Class represents an NLME/PML error model

Arguments

effectsList

List of residual effects to include in the error model

numberOfEffects

Number of effects being included in the error model


Class represents an NLME/PML Indirect PD model parameters

Description

Class represents an NLME/PML Indirect PD model parameters

Arguments

type

Indirect model type

hasEffectsCompartment

Is there data available for an effects compartment?

isBuildup

Is the response formation (TRUE) or degradation (FALSE) concentration dependent?

isExponent

Is there an exponent in the effect statement?

frozen

Freeze standard deviation to prevent estimation of the PK part of the model


Reads progress file and returns the status of a job

Description

Reads progress file and returns the status of a job

Usage

NlmeJobStatus(job)

Arguments

job

NLME job object

Value

Character. Job status messages.

Examples


  model <- pkmodel(
    parameterization = "Clearance",
    numCompartments = 2,
    data = pkData,
    ID = "Subject",
    Time = "Act_Time",
    A1 = "Amount",
    CObs = "Conc",
    workingDir = tempdir()
  )

  params <- NlmeEngineExtraParams(
    method = 3,
    numIterations = 1
  )

  host <- hostParams(
    sharedDirectory = tempdir(),
    parallelMethod = "LOCAL_MPI",
    hostName = "local_mpi",
    numCores = 4
  )

  profile1 <- ProfileVar(
    "tvV",
    9.548,
    "-2,0"
  )

  profile2 <- ProfileVar(
    "tvCl",
    0.919,
    "-0.5,0"
  )

  profiles <- ProfileParameters(
    "USE_DELTA",
    c(profile1, profile2)
  )

  job <- profilePertubate(
    hostPlatform = host,
    params = params,
    profiles = profiles,
    model = model
  )

  status <- NlmeJobStatus(job)



Class initializer for NlmeObservationVar-class

Description

Describes an observation(observe,multi,...)

Arguments

name

Name of observation variable

xaxis

One of: T, TAD, PRED. If nothing is specified, the user-specified name of axis is used.

binningMethod

Method of binning: "none" (default), "KMEANS", "CENTERS", "BOUNDARIES"

binningOption

Centers or boundary values specified as numeric vector

stratifyColumns

Categorical covariates (up to 3) for simulation stratification (overrides stratifyColumns given in NlmeVpcParams)

ygroup

Values specifying the category right boundaries (used for categorical observations only; useful for count)

quantilesValues

Quantiles to be estimate for each x value (bin value) in each strata for the current observable (internal quantiles)

quantilesSecondaryValues

Quantiles to estimate for each internal quantile (quantiles for quantile)

BQLasLLOQ

Flag to replace BLQ values with the LLOQ value

Examples


var <- NlmeObservationVar(
  name = "Cobs",
  xaxis = "t",
  binningMethod = "none",
  quantilesValues = c(5, 50, 95)
)

NlmeParallelHost Class

Description

This class defines an NLME parallel host, which can be either local or remote, for running jobs.

Slots

sharedDirectory

character. The directory where the run will take place. On Windows, UNC paths are mapped to a drive letter for local execution.

installationDirectory

character. The directory containing NLME libraries and scripts.

hostName

character. A user-friendly name for the host (e.g., "local_mpi").

machineName

character. The IP address or hostname of the machine. Defaults to the local system's node name.

hostType

character. The operating system of the host, either "windows" or "linux". For remote Linux systems, you can specify a supported distribution (e.g., "RHEL", "UBUNTU") to configure the PML_BIN_DIR environment variable. linux will be treated as "RHEL".

numCores

numeric. The number of compute cores to be used.

isLocal

logical. TRUE if the host is local, FALSE if remote.

rLocation

character. The path to the Rscript executable on a remote host. This is ignored for local runs.

scriptPath

character. The path to a script to execute on the remote host before Rscript is started. This is ignored for local runs.

userAuthentication

NlmeUserAuthentication. An object containing user credentials for remote host authentication. See NlmeUserAuthentication().

parallelMethod

NlmeParallelMethod. The parallel computing method to use (e.g., "LOCAL_MPI", "SGE", "TORQUE"). See NlmeParallelMethod().

Examples

host <- hostParams(
  parallelMethod = "LOCAL_MPI",
  hostName = "local_mpi",
  numCores = 4
)


Class initializer for NlmeParallelMethod

Description

Use to define NlmeParallelMethod as for parallelMethod argument in NlmeParallelHost().

Slots

method

Options are: None|Multicore|LOCAL_MPI|SGE|SGE_MPI|TORQUE|TORQUE_MPI|LSF|LSF_MPI|SLURM|SLURM_MPI.


Class represents mapping list between model variables and data columns

Description

Class represents mapping list between model variables and data columns


Class represents an NLME/PML PK model parameters

Description

Class represents an NLME/PML PK model parameters

Arguments

parameterization

Taken from NlmeModelParameterization

absorption

Taken from NlmeModelAbsorption

numCompartments

Number of compartments

isTlag

Does dose have a time lag?

hasEliminationComp

Is there data available for an elimination compartment?

isFractionExcreted

Does compartment include a fraction excreted parameter?

isSaturating

Is the elimination rate equal to the absorption rate?

infusionAllowed

Is infusion allowed?

isDuration

Is duration of infusion measured (TRUE) or rate (FALSE)?

isSequential

Is model part of a PK/PD model that is being fitted sequentially?

isClosedForm

Is model closed-form algebraic (TRUE) or differential equation (FALSE)?


Class initializaer for NlmePmlModel object

Description

The following class represents an NLME/PML model object.

Slots

isPopulation

Is this a population model (TRUE) or individual (FALSE)?

modelType

Taken from NlmeModelType

isTimeBased

Is model time-based?

linearModelType

Type of linear model

isLinearFrozen

Is linear model frozen?

pkModelAttrs

Taken from NlmePkParameters

indirectModelAttrs

Taken from NlmeIndirectParameters

emaxModelAttrs

Taken from NlmeEmaxParameters

hasEffectsCompartment

Is there data available for an effects compartment?

errorModel

Taken from NlmeErrorModel

structuralParams

List of structural parameters

outputParams

List of output parameters

diffEquations

List of differential equations

statements

List of PML statements

dosePoints

List of dosepoints

covariateList

List of covariates

columnMapping

Taken from NlmeColumnMapping

doseMapping

Taken from NlmeDoseMapping

paramsMapping

Taken from NlmeParamsMapping

randParamsMapping

Taken from NlmeRandParamsMapping

inputData

Input data source

doseData

Dose data source

fixedParamData

Fixed effect parameter data source

randParamData

Random effect parameter data source

isTextual

Is model textual (TRUE) or graphical (FALSE)?

pmloutput

List of PML output to generate

modelInfo

Taken from NlmePmlModelInfo

objects

deprecated

objectsNeedRegenerating

deprecated

randomEffectsStatements

Custom random effects statements

randomOccasionalEffectsStatements

Custom random occasional effects statements

userDefinedExtraDefs

Custom definition for extra column and table generation

Examples


# helper class
setClass("NlmePmlModelInfo",
         slots = c(modelName = "character",
                   workingDir = "character"))
Model <-
  new("NlmePmlModel",
  modelInfo = new("NlmePmlModelInfo", modelName = "Model", workingDir = "."))



Class initializer for NlmeRemoteExecutor

Description

Creates Remote Executor object class

Slots

sharedDirectory

The directory in which the run executes

installationDirectory

Directory containing NLME libraries/scripts

hostName

IP or name of remote host

userAuthentication

Credential for user to log into remote system


Class represents an NLME/PML residual error model

Description

Class represents an NLME/PML residual error model

Arguments

effectName

Name of the observed variable

observeName

Name to use for observation

epsilonName

Name to use for Epsilon

errorType

Additive|LogAdditive|Multiplicative |AdditiveMultiplicative|MixRatio|Power|Custom

frozen

Is the standard deviation frozen? (Default:FALSE)

SD

Standard deviation value

definition

Definition of a custom type or Power value

isBQL

Are there BQL values? (Default:FALSE)

bqlStatic

Value LLOQ value

dobefore

Code to execute before the observation

doafter

Code to execute after the observation


Class initializer for NlmeScenario

Description

Creates NlmeScenario class object

Arguments

scenarioName

Name of the scenario

covariatesList

Comma separated indices of covariate effects to use for this scenario

Examples

CovariateEffectNames <- c("dVdBodyWeight",  "dCldBodyWeight")
#   Do not use any covariate effects
scenario1 <- NlmeScenario("no_covariates", "")
#   Use covariate effect index 1
scenario2 <- NlmeScenario("dVdBodyWeight", "1")
#   Use second covariate effect in the model
scenario3 <- NlmeScenario("dCldBodyWeight", "2")
#   Use 1st and 2nd covariate effect
scenario4 <- NlmeScenario("dVdBodyWeight_dCldBodyWeight", "1,2")

Class initializer for NlmeSimTableDef

Description

Creates NlmeSimTableDef class object used to specify parameters for VPC/Simulation runs

Arguments

name

Name of the generated simulation file.

timesList

Numeric; Time values for simulation. Applicable for time-based models only. Ignored when "keepSource=TRUE"

covrSet

Character; Vector of covariate names. Simulation point is added when the covariate value is set. See covariateNames

whenDose

Character; Vector of dosing compartment names. Simulation point is added when the dose value is set.

whenObs

Character; String of observed variables names. Simulation point is added when the observation value is set.

variablesList

Character; List of variables from the model for simulation.

keepSource

Logical; Set to TRUE to keep the number of rows appearing in the table the same as the number of rows in the input dataset.

timeAfterDose

Set to TRUE to output time after dose.


Class initializer for NlmeSimulationParams

Description

Use to create set of parameters for simulation runs. Parameters numPoints, maxXRange, yVariables, simAtObs are related to the model in individual mode. They will be outputted to the file specified in model@dataset@simoutFilename, simout.csv by default

Arguments

numReplicates

Number of replicates to simulate

seed

Random number generator seed

numPoints

Number of points in simulation for the models in individual mode

maxXRange

Maximum value of independent variable for the models in individual mode

yVariables

Comma separated character string of Y variables for the models in individual mode

simAtObs

Simulate values at observed values of ivar for the models in individual mode

simulationTables

Optional list of simulation tables. NlmeSimTableDef class instance or a list of such instances. Could be generated by tableParams wrapper function or by NlmeSimTableDef class instance initializing directly.

See Also

tableParams, NlmeSimTableDef

Examples


table1 <- tableParams(
  name = "simulate.csv",
  timesList = "0,2,4,12,24",
  variablesList = "V,Cl",
  timeAfterDose = TRUE,
  forSimulation = TRUE
)

simParam <- NlmeSimulationParams(
  numReplicates = 10,
  seed = 29423,
  simulationTables = c(table1)
)

simParam <- NlmeSimulationParams(
  numPoints = 100,
  maxXRange = 50,
  yVariables = "C,A1",
  simulationTables = table1
)


Class represents style of structural parameter

Description

Class represents style of structural parameter

Slots

style

Parameter style: 1=LogNormal, 2=Normal, 3=Combination, 4=Log, 5=Logit


Class initializer for NlmeTableDef

Description

Creates NlmeTableDef class object used to specify parameters for fitting runs

Arguments

name

Name of the generated simulation file.

timesList

Numeric; Time values for simulation. Applicable for time-based models only. Ignored when "keepSource=TRUE"

covrSet

Character; Vector of covariate names. Simulation point is added when the covariate value is set. See covariateNames

whenDose

Character; Vector of dosing compartment names. Simulation point is added when the dose value is set.

whenObs

Character; String of observed variables names. Simulation point is added when the observation value is set.

variablesList

Character; List of variables from the model for simulation.

keepSource

Logical; Set to TRUE to keep the number of rows appearing in the table the same as the number of rows in the input dataset.

timeAfterDose

Set to TRUE to output time after dose.

IRES

Logical; Set to TRUE to output individual residuals. Valid only if whenObs is specified.

Weight

Logical; Set to TRUE to output the weight of current observation. Valid only if whenObs is specified.

IWRES

Logical; Set to TRUE to output individual weighted residuals. Valid only if whenObs is specified.

mode

Character; The mode of output. Options are "all" (default), "unique", "first". Only applicable to non time-based models for the case where only covrSet is defined or the case where only covrSet and variablesList are defined.

Option "all" (default): it outputs all the rows invoked by specified covariates. Option "unique": if the values in a row are the same as the ones in the previous row for the current subject, then the row is omitted; otherwise, it is printed out. Option "first": it outputs only the first row for each subject.


Class initializer for NlmeUserAuthentication

Description

Use for authentication records

Slots

userName

How the user is identified to the remote system

privateKeyFile

path to private key file, see keyfile for details

userPassword

either a string or a callback function for password prompt, see passwd for details


Arguments for VPC runs

Description

Class initializer for arguments of visual predictive check (VPC) runs

Arguments

numReplicates

Integer; Number of replicates to simulate the model

seed

Integer; Random number generator seed

predCorrection

Character; Type of correction to use when calculating a prediction-corrected observation. Options are "none", "proportional", "additive". This option is ignored for discontinuous observed variables (categorical, count, and time-to-event).

predVarCorr

Logical; Set to TRUE to use Prediction Variance Correction. Only applicable to the case where predCorrection is set to either "proportional" or "additive".

outputPRED

Logical; Set to TRUE to include population prediction (PRED) results for continuous observed variables in output.

stratifyColumns

Character or character vector; Names of categorical covariates (up to 3) used to stratify modeling simulation results.

observationVars

NlmeObservationVar class instance or list of these instances

simulationTables

Optional list of simulation tables. NlmeSimTableDef class instance or a list of such instances. Could be generated by tableParams wrapper function or by NlmeSimTableDef class instance initializing directly.

See Also

tableParams, NlmeSimTableDef, NlmeObservationVar

Examples


model <- pkmodel(
  parameterization = "Clearance",
  numCompartments = 2,
  data = pkData,
  ID = "Subject",
  Time = "Act_Time",
  A1 = "Amount",
  CObs = "Conc",
  workingDir = tempdir()
  )

# Define the host
host <- hostParams(parallelMethod = "NONE",
                   hostName = "local",
                   numCores = 1,
                   sharedDirectory = tempdir())
job <- fitmodel(model,
                hostPlatform = host)

# View estimation results
print(job)

finalModelVPC <- copyModel(model,
                           acceptAllEffects = TRUE,
                           modelName = "model_VPC",
                           workingDir = tempdir())

# View the model
print(finalModelVPC)

# Set up VPC arguments to have PRED outputted to simulation output dataset "predout.csv"
vpcSetup <- NlmeVpcParams(outputPRED = TRUE)

# Run VPC using the default host, default values for the relevant NLME engine arguments
finalVPCJob <-
  vpcmodel(model = finalModelVPC, vpcParams = vpcSetup, )




Pharmacokinetic dataset containing 100 subjects with single dose given by infusion

Description

Pharmacokinetic dataset containing 16 subjects with single dose given by infusion.

Usage

OneCpt_IVInfusionData

Format

A data frame with 800 rows and 6 variables:

Subject

Subject ID

Time

Time point

Dose

Amount of dose

CObs

Observations of drug concentration in blood

Rate

Rate of infusion

Duration

Duration of infusion

Source

The data is simulated using a PK model described by a one-compartment model with IV infusion


Class initializer for ProfileParameters

Description

Class represents an NLME profile perturbation variable

Slots

howToPertubate

How to apply profile variables. Options are USE_DELTA or USE_PERCENTAGE

profileVars

List of profile variables

Examples

profile1 <- ProfileVar("tvV", 9.548, "-2,-1,0,1,2")
profile2 <- ProfileVar("tvCl", 3.219, "-1,0,1")
profiles <- ProfileParameters("USE_DELTA", c(profile1, profile2))

NLME Profile variable

Description

Class initializer for an NLME profile perturbation variable

Arguments

effectName

Name of fixed effect

initialvalue

Initial value

pertubateValues

Values to perturbate by (either delta or percentage)

Examples

ProfileVar("tvV", 9.95, "-2,-1,0,1,2")

Class initializer for ResetColumnInfo

Description

Class initializer for ResetColumnInfo

Arguments

low

Lower value of reset range

hi

Upper value of reset range


Execute an NLME profile perturbation

Description

Execute an NLME profile perturbation

Usage

RunProfilePertubation(
  hostPlatform,
  dataset,
  params,
  profiles,
  sortColumns,
  scenarios = list(),
  runInBackground = FALSE,
  workingDir = NULL
)

Arguments

hostPlatform

How to execute the run(NlmeParallelHost)

dataset

Dataset and model information(NlmeDataset)

params

Engine parameters(NlmeEngineExtraParams)

profiles

Profiles to perturbate(ProfileParameters)

sortColumns

Optional list of columns to sort and fit(SortColumns)

scenarios

Optional list of scenarios to fit(NlmeScenario)

runInBackground

TRUE will run in background and return prompt(Bool)

workingDir

Directory in which to run the job. Current working directory is used if NULL

Value

Object of class ProfileNlmeJob

Examples


  model <- pkmodel(
    parameterization = "Clearance",
    numCompartments = 2,
    data = pkData,
    ID = "Subject",
    Time = "Act_Time",
    A1 = "Amount",
    CObs = "Conc",
    workingDir = tempdir()
  )

  params <- NlmeEngineExtraParams(
    method = 3,
    numIterations = 1
  )

  host <- hostParams(
    sharedDirectory = tempdir(),
    parallelMethod = "None",
    hostName = "Local",
    numCores = 4
  )

  profile1 <- ProfileVar(
    "tvV",
    9.548,
    "-2,0,2"
  )

  profile2 <- ProfileVar(
    "tvCl",
    0.919,
    "-0.5,0,1.5"
  )

  profiles <- ProfileParameters(
    "USE_DELTA",
    c(profile1, profile2)
  )

  job <- profilePertubate(
    hostPlatform = host,
    params = params,
    profiles = profiles,
    model = model
  )


Class initializer for SortColumns

Description

Class represents an NLME sort columns object

Arguments

...

Names of input data columns (up to 5 for individual models and no limit for population models) used to sort the input data and model outputs. Can be supplied as either a single string or a vector of strings.

Examples

# The following two setups are equivalent
sortColumnSetUp <- SortColumns("Country,City")
sortColumnSetUp <- SortColumns(c("Country","City"))

# The following two setups are equivalent
sortColumnSetUp <- SortColumns("Sort1 Sort2", "Sort3")
sortColumnSetUp <- SortColumns(c("Sort1, Sort2 "), "Sort3 ")

Class initializer for NLME StepwiseParams

Description

Class represents an NLME Stepwise search parameters

Arguments

addPValue

Numeric. Threshold for adding a covariate effect

removePValue

Numeric. Threshold for removing a covariate effect

method

-2LL|AIC|BIC; could be abbreviated.

Examples

StepwiseParams(0.001, 0.001, "BIC")

Accepts all estimates for fixed effects, Sigma, and random effects

Description

Updates PML statements in model object with estimates returned from model execution. Use copyModel and set argument acceptAllEffects = TRUE to create new model object with final estimates from base model run.

Usage

acceptAllEffects(model)

Arguments

model

Model object

Value

NlmePmlModel object

See Also

copyModel

Examples


# Define the model
model <- pkmodel(numComp = 1,
                 absorption = "Intravenous",
                 ID = "Subject",
                 Time = "Act_Time",
                 CObs = "Conc",
                 A1 = "Amount",
                 data = pkData,
                 modelName = "PkModel",
                 workingDir = tempdir())

# Fit model
res <- fitmodel(model = model,
                hostPlatform = hostParams(sharedDirectory = tempdir()))
model <- acceptAllEffects(model)


Adds ADDL extra column definition to model object

Description

Specify ADDL column definition in model object instead of specifying ADDL through addDoseCycle

Usage

addADDL(.Object, ADDL, II)

Arguments

.Object

Model object

ADDL

Column mapping argument specifying corresponding "ADDL" column in input data set

II

Column mapping argument specifying corresponding "II" column in input data set

Value

Modified NlmePmlModel object

Examples


pkData1 <- pkData
pkData1$ii <- 0
pkData1$addl <- 0
 model <- pkmodel(numComp = 2,
                  absorption = "FirstOrder",
                  ID = "Subject",
                  Time = "Act_Time",
                  CObs = "Conc",
                  Aa = "Amount",
                  data = pkData1,
                  modelName = "PkModel",
                  workingDir = tempdir())
 model <- addADDL(model, ADDL = "addl", II = "ii")



Add covariate to model object

Description

Add a continuous, categorical, or occasion covariate to model object and set covariate effect on structural parameters.

Usage

addCovariate(
  .Object,
  covariate,
  effect = NULL,
  type = c("Continuous", "Categorical", "Occasion"),
  direction = c("Forward", "Interpolate", "Backward"),
  option = c("Yes", "PlusOne", "No"),
  center = NULL,
  centerValue = NULL,
  levels = NULL,
  labels = NULL,
  isDiagonal = TRUE,
  values = NULL,
  isPositive = TRUE
)

Arguments

.Object

Model object

covariate

Name of covariate. If the involved model has columns mapped (i.e. model with columnMap = TRUE) use named character if the name of the covariate is different from the corresponding column in the input dataset, for example, covariate = c(BW = "BodyWeight"), where BW denotes the name of the covariate, and "BodyWeight" is the name of the corresponding column in the input dataset.

effect

Name of structural parameter(s) on which the covariate has an effect. Specify effect as character or character vector if the covariate has an effect on multiple structural parameters. Important for Occasion Covariates: When modifying an existing occasion covariate (e.g., changing option or values), you must list all structural parameters currently affected by this occasion covariate in the effect argument, even those whose effect relationship is not being changed in this specific call.

type

Type of covariate. Options are "Continuous", "Categorical", "Occasion".

direction

Direction of missing values propagation (if no covariate value is given). Options are "Forward", "Interpolate", "Backward", where "Interpolate" is only applicable to type = "Continuous".

option

Options are "Yes", "PlusOne", or "No".

  • "Yes": Apply the covariate effect using the standard method (multiplicative for LogNormal style, additive for Normal style).

  • "PlusOne": Apply the covariate effect using the "1 + effect" formulation. This is only applicable to continuous and categorical covariates where the affected structural parameter has style = "LogNormal".

  • "No": Remove the specified covariate effect from the specified structural parameter(s). The covariate itself (and its definition, e.g., fcovariate(Occ1)) remains part of the model, but the link between this covariate and the specified parameter(s) in the stparm() statement is removed. See the note for the effect argument regarding occasion covariates. Multiple options are not supported within a single call (i.e., all covariate effects listed in the effect argument for a single call must use the same option). If different options are required, use sequential calls to addCovariate.

center

Centering method. Options are "Mean", "Median", "Value" or "None". Only applicable to covariate type = "Continuous". Must include argument centerValue if center = "Value".

centerValue

Value used to center covariate. Only applicable if argument center = "Value" and type = "Continuous".

levels

Unique values of categorical or occasion covariate. Only applicable to covariate type = "Categorical" or type = "Occasion".

labels

Label names (in the same order as levels) for unique levels of categorical or occasion covariate in data. Only applicable to covariate type = "Categorical" or type = "Occasion" where its corresponding column in the input dataset has character type.

isDiagonal

Set to FALSE if inter-occasion covariance matrix is not diagonal matrix. Only applicable to covariate type = "Occasion".

values

Initial values for the diagonal elements of the inter-occasion covariance matrix (if isDiagonal = TRUE) or initial values for the lower triangular elements (including diagonal elements) of inter-occasion covariance matrix (if isDiagonal = FALSE) in a row-wise order. Only applicable for covariate type = "Occasion".

isPositive

Set to FALSE if covariate contains negative values. Only applicable to covariate type = "Continuous".

Details

The following relationships are applicable for covariates:

Value

Modified NlmePmlModel object

Examples

model <- pkmodel(
  numCompartments = 2,
  data = pkData,
  ID = "Subject",
  Time = "Act_Time",
  A1 = "Amount",
  CObs = "Conc",
  workingDir = tempdir()
)

# Add Gender covariate of type categorical
model <- addCovariate(model,
  covariate = "Gender",
  type = "Categorical",
  effect = c("V2", "Cl2"),
  levels = c(0, 1),
  labels = c("Female", "Male")
)

# Add BodyWeight covariate of type continuous
model <- addCovariate(model,
  covariate = "BodyWeight",
  type = "Continuous",
  direction = "Backward",
  center = "Mean",
  effect = c("V", "Cl")
)

Adds a dosing cycle to model

Description

Add Steady State or ADDL dosing cycle to model object.

Usage

addDoseCycle(
  .Object,
  type = "SteadyState",
  name,
  administration = "Bolus",
  amount = NULL,
  II = NULL,
  rate = NULL,
  duration = NULL,
  isSecondDose = FALSE,
  colName = NULL
)

Arguments

.Object

Model object

type

Specification of dose type. Options are "SteadyState"and "ADDL"

name

Dose point name. See doseNames

administration

Mechanism for administering dose. Options are "Bolus" or "Infusion"

amount

Optional. Column mapping argument specifying corresponding "ADDL" column in input data, or numeric value specifiying dose amount.

II

Optional. Column mapping argument specifying corresponding "II" column in input data, or numeric value specifying delta time.

rate

Optional. Column mapping argument specifying corresponding "Rate" column in input data, or numeric specifying dose rate.

duration

Optional. Column mapping argument specifying corresponding "Duration" column in data, or numeric specifying duration value.

isSecondDose

Use second dose point on compartment

colName

Column name in input data corresponding to column mapping for "SteadyState" or "ADDL" as supplied in type argument.

Value

Modified NlmePmlModel object

See Also

doseNames

Examples


model <- addDoseCycle(pkmodel(columnMap = FALSE,
                              isPopulation = FALSE,
                              workingDir = tempdir()),
                      type = "SteadyState",
                      name = "A1",
                      amount = "Amount",
                      II = "II")



Adds user defined extra column/table definitions to column definition file

Description

Adds user defined extra column/table definitions to column definition file

Usage

addExtraDef(.Object, value)

Arguments

.Object

PK/PD model

value

Character vector of extra column/table definitions

Value

Modified NlmePmlModel object

Examples


model <- pkmodel(columnMap = FALSE,
                 workingDir = tempdir())
model <- addExtraDef(model, c("addlcol(ADDL)",
                              "table(file=\"res.csv\",time(0),Ka,V,Cl,Tlg)"))



Change existing dosing compartment to infusion

Description

Allows user to switch any dosing compartment to infusion

Usage

addInfusion(
  .Object,
  doseCptName,
  isDuration = FALSE,
  isSecondDose = FALSE,
  colName = NULL
)

Arguments

.Object

Model object

doseCptName

Name of the compartment to which the dose is administered

isDuration

Set TRUE if duration is used to specify infusion information

isSecondDose

Set TRUE if doseCptName is specified in the model through dosepoint2 statement

colName

Name of the input data column that represents the corresponding infusion rate. If not provided, colName must be mapped through colMapping().

Value

Modified NlmePmlModel object

Examples


 pkData1 <- pkData
 pkData1$A1_1 <- 0
 model <- pkmodel(numComp = 2,
 absorption = "Intravenous",
 ID = "Subject",
 Time = "Act_Time",
 CObs = "Conc",
 A1 = "Amount",
 data = pkData1,
 modelName = "PkModel",
 workingDir = tempdir())
 newModel <- addInfusion(model, "A1", FALSE, FALSE, "A1_1")



Add levels and labels to categorical or occasion covariate

Description

Allows users to specify the name and the associated value for each category/occasion of a categorical/occasion covariate in a textual model object. Only applicable to the case where the corresponding input data column of a categorical/occasion covariate is of class character.

Usage

addLabel(.Object, covariate, levels, labels)

Arguments

.Object

Model object

covariate

Existing covariate name

levels

Unique values of categorical or occasion covariate column specified as numeric vector

labels

Unique values specifying corresponding label names for levels of categorical or occasion covariate column in data specified as character vector.

Value

Modified NlmePmlModel object

Examples


model <- pkmodel(columnMap = FALSE,
                 isPopulation = FALSE,
                 workingDir = tempdir())

model <- suppressWarnings(addCovariate(model,
                      covariate = "Gender",
                      type = "Categorical",
                      effect = c("V"),
                      levels = c(0, 1)))
model@isTextual <- TRUE
model <- addLabel(model, "Gender", c(1, 2), c("male", "female"))



Adds MDV extra column definition to model object

Description

Use to add MDV statement to model@userDefinedExtraDefs

Usage

addMDV(.Object, MDV)

Arguments

.Object

Model object

MDV

Column mapping argument specifying corresponding "MDV" column in input data set

Value

Modified NlmePmlModel object

Examples


pkData1 <- pkData
pkData1$MDV <- 0
model <- pkmodel(data = pkData1,
                 ID = "Subject",
                 Time = "Act_Time",
                 A1 = "Amount",
                 CObs = "Conc",
                 workingDir = tempdir()
                 )
model <- addMDV(model, MDV = "MDV")


Adds reset instructions to the model

Description

Adds reset instructions to the model

Usage

addReset(.Object, low, hi, Reset = NULL)

## S4 method for signature 'NlmePmlModel'
addReset(.Object, low, hi, Reset = NULL)

Arguments

.Object

An 'NlmePmlModel' object to which you want to add reset instructions.

low

Lower value of reset range.

hi

Upper value of reset range.

Reset

Name of reset column in input data set for column mapping. The default is NULL.

Value

Depends on the specific methods

Returns the 'NlmePmlModel' object with updated reset information and definitions.

Functions


Adds a secondary parameter to model definition

Description

Adds a secondary parameter to model definition

Usage

addSecondary(.Object, name, definition, unit = "")

## S4 method for signature 'NlmePmlModel'
addSecondary(.Object, name, definition, unit = "")

Arguments

.Object

An 'NlmePmlModel' object to which you want to add a secondary parameter.

name

Name of the secondary parameter.

definition

Definition of secondary parameter.

unit

Optional units of the secondary parameter. The default is "".

Value

Depends on the specific methods

Returns the 'NlmePmlModel' object with the added secondary parameter.

Functions

Examples


model <- pkmodel(columnMap = FALSE,
                 absorption = "FirstOrder",
                 workingDir = tempdir())
model <- addSecondary(model, "Ke", "tvCl/tvV")
model <- addSecondary(
  model, "Tmax",
  "CalcTMax(tvA,tvCl/tvV)"
)



Adds Steady State extra column definition to model object

Description

Use to add Steady State column definition statement to model@userDefinedExtraDefs

Usage

addSteadyState(.Object, SS, II, SSOffset = NULL)

Arguments

.Object

Model object

SS

Column mapping argument specifying corresponding "SS" column in input data set

II

Column mapping argument specifying corresponding "II" column in input data set

SSOffset

Optional. Column mapping argument specifying corresponding "SSOffset" column in input data set

Value

Modified NlmePmlModel object

Examples


pkData1 <- pkData
pkData1$SS <- 0
pkData1$II <- 0
model <- pkmodel(data = pkData1,
                 ID = "Subject",
                 Time = "Act_Time",
                 A1 = "Amount",
                 CObs = "Conc",
                 workingDir = tempdir()
                 )
model <- addSteadyState(model, SS = "SS", II = "II")


Add to the NLME Error model

Description

Add to the NLME Error model

Usage

addToErrorModel(model, effectsList)

Arguments

model

Model object

effectsList

List of effects


Executes an NLME Bootstrap

Description

Method to execute an NLME Bootstrap

Usage

bootstrap(
  model,
  hostPlatform = NULL,
  params,
  bootParams,
  runInBackground = FALSE,
  ...
)

Arguments

model

PK/PD model class object.

hostPlatform

Host definition for model execution. See hostParams. If missing, multicore local host with 4 threads is used.

params

Engine parameters. See engineParams. If missing, default parameters generated by engineParams(model) are used.

bootParams

Bootstrap parameters. See BootstrapParams. If missing, default parameters generated by BootstrapParams() are used.

runInBackground

Set to TRUE to run in background and return prompt.

...

Additional class initializer arguments for BootstrapParams or hostParams, or arguments available inside engineParams functions. If engineParams arguments are supplied through both params argument and additional argument (i.e., ellipsis), then the arguments in params will be ignored and only the additional arguments will be used with warning. If hostParams arguments are supplied through both hostPlatform argument and additional argument, then its values will be overridden by additional arguments. In addition, if BootstrapParams arguments are supplied through both bootParams argument and additional argument, then its slots will be overridden by additional arguments.

Value

if runInBackground = FALSE, a list is returned with bootstrap results, i.e. "BootOverall", "BootTheta", "BootOmega", "BootOmegaStderr", "BootVarCoVar" comma separated files. Otherwise the BootNlmeJob class object is returned.

See Also

hostParams, engineParams, BootstrapParams

Examples


input_data <- pkData

model <-
  pkmodel(
    numCompartments = 2,
    data = input_data,
    ID = "Subject",
    Time = "Act_Time",
    A1 = "Amount",
    CObs = "Conc",
    workingDir = tempdir()
  )

# multicore
multicoreHost <- hostParams(
  sharedDirectory = tempdir(),
  parallelMethod = "Multicore",
  hostName = "local_multicore",
  numCores = 4
)

bootstrapdf <- bootstrap(model,
  hostPlatform = multicoreHost,
  params = engineParams(model),
  numReplicates = 5,
  randomNumSeed = 1234,
  runInBackground = FALSE
)



Generic function for cancelling a job

Description

Generic function for cancelling a job

Usage

cancelJob(.Object)

## S4 method for signature 'SimpleNlmeJob'
cancelJob(.Object)

Arguments

.Object

A 'SimpleNlmeJob' object that you want to cancel

Value

Depends on the specific methods

Prints the 'SimpleNlmeJob' object after attempting to cancel the job. No return value.

Functions


Check Host Parameters

Description

Checks NLME Parallel Host object for correct settings for GCC, NLME Installation, MPI and Root directories.

Usage

checkHostParams(obj, verbose = FALSE)

Arguments

obj

NLME Parallel Host to be checked

Value

TRUE if all checks are successful, otherwise FALSE

Examples



# multicore
multicoreHost <- hostParams(
  parallelMethod = "Multicore",
  hostName = "local_multicore",
  numCores = 4
)
checkHostParams(multicoreHost)



Add column mappings

Description

Piping compatible function for modelColumnMapping used to add column mappings from input data to model object

Usage

colMapping(.Object, mappings = NULL, ...)

Arguments

.Object

Model (NlmePmlModel) object

mappings

Named character vector specifying valid column names in the input data. Character vector names must be valid model variable names contained in modelVariableNames(model).

...

optional pairs ModelTerm = ColumnName or ModelTerm = "ColumnName". Has higher precedence than mappings if some ModelTerm is mapped twice in mappings and in .... For multiple mapping, i.e. id mapping, a vector should be provided with the names of columns. See example below.

Value

modified NlmePmlModel object

See Also

dataMapping modelVariableNames

Examples

pkData$id2 <- pkData$Subject
model <- pkmodel(columnMap = FALSE,
                 data = pkData,
                 workingDir = tempdir())

modelvar <- unlist(modelVariableNames(model))

colnames <- c("Subject", "Act_Time", "Amount", "Conc")
names(colnames) <- modelvar
# will map subject directly
colnames <- colnames[-c(1)]

model <- colMapping(model, colnames, id = c(Subject, id2))
# also possible:
model <- colMapping(model, colnames, id = c("Subject", "id2"))
# not recommended since only not quoted names are identified
# if both types are provided:
model <- colMapping(model, colnames, id = c("Subject", id2))


Copy model object to iterate over base model

Description

Copies previously executed model into a new object and optionally accept all estimates returned from model execution. A new working directory is created and all files from base model are copied into it.

Usage

copyModel(model, acceptAllEffects = FALSE, modelName = "", workingDir = "")

Arguments

model

Model object to be copied

acceptAllEffects

Set to TRUE to accept all effects, update PML statements, and test.mdl file from original model run

modelName

New model name for subdirectory created for model output. Subdirectory is created in current working directory.

workingDir

Working directory to run the model. Current working directory will be used if workingDir not specified.

Value

Modified NlmePmlModel object

Examples


model <- pkmodel(
  parameterization = "Clearance",
  numCompartments = 2,
  data = pkData,
  ID = "Subject",
  Time = "Act_Time",
  A1 = "Amount",
  CObs = "Conc",
  workingDir = tempdir()
  )
 host <- hostParams(sharedDirectory = tempdir(),
                    parallelMethod = "None",
                    hostName = "local",
                    numCores = 1)
job <- fitmodel(model,
                numIterations = 3,
                hostPlatform = host)

finalModelVPC <- copyModel(model,
                           acceptAllEffects = TRUE,
                           modelName = "model_VPC",
                           workingDir = tempdir())



Sets style for a covariate/variable

Description

Sets style for a covariate/variable

Usage

covariateEffect(.Object, covariateName, parameterName) <- value

Arguments

.Object

A PK/PD model

covariateName

Name of the covariate

parameterName

Name of the model variable

value

A value to set


Creates set of covariate effects

Description

Use to create set of covariate effects to be checked during Stepwise or Shotgun covariate search

Usage

covariateModel(model)

Arguments

model

Model object with covariates and covariate effects specified

Value

CovariateEffectModel class object

Examples


# Define the model
model <- pkmodel(
  numCompartments = 2,
  data = pkData,
  ID = "Subject",
  Time = "Act_Time",
  A1 = "Amount",
  CObs = "Conc",
  workingDir = tempdir()
)

# Add Gender covariate of type categorical
model <- addCovariate(model,
  covariate = "Gender",
  type = "Categorical",
  effect = c("V2", "Cl2"),
  levels = c(0, 1),
  labels = c("Female", "Male")
)

# Add Bodyweight covariate of type continuous
model <- addCovariate(model,
  covariate = "BodyWeight",
  type = "Continuous",
  direction = "Backward",
  center = "Mean",
  effect = c("V", "Cl")
)
covariateModel(model)


Return covariate names

Description

Use to return character vector of covariate names available in model object.

Usage

covariateNames(model)

Arguments

model

Model object

Value

Character vector of covariate names defined in model

Examples

model <- pkmodel(columnMap = FALSE,
                 workingDir = tempdir())
model <- addCovariate(model, covariate = "BW", effect = "V")
model <- addCovariate(model, covariate = "Age", effect = "Cl")

covariateNames(model)


Creates string from each covariate attribute

Description

Creates string from each covariate attribute

Usage

covariatePartsString(obj)

Arguments

obj

Model covariate


Parse the model and get the list of terms

Description

Calls TDL5 to parse the model and get the list of terms

Usage

createModelInfo(model, ForceRun = FALSE)

Arguments

model

Model object

ForceRun

Set to TRUE to force run

Value

List of model information

Examples


  model <- pkmodel(columnMap = FALSE,
                   workingDir = tempdir())
  createModelInfo(model)



Use to create model object from parsed metamodel

Description

Define NlmePmlModel model class instance from metamodel blocks and creates NlmePmlModel model class from the given parsed metamodel. See Metamodel overview.

Usage

create_model_from_metamodel(mmdlfile, directoryToRun)

Arguments

mmdlfile

File with metamodel description

directoryToRun

Directory where the results will be stored; if missing, a subfolder in the current directory with the model name given in parsedMetamodel will be created

Value

a list with the resulted model class instance and engine parameters. If multiple ESTARGS/SIMARGS blocks are used, a list of estimation argument classes (NlmeEngineExtraParams()) and simulation argument classes (simParamsBlock) are returned.

See Also

run_metamodel()

Examples

 
   ModelParamsList <-
     create_model_from_metamodel(
       mmdlfile = system.file("extdata/mmdlNoTime", "test.mmdl",
                              package = "Certara.RsNLME"),
       directoryToRun = tempdir())
 


Initialize input data for PK/PD model

Description

Used to initialize input data for PK/PD model

Usage

dataMapping(.Object, data)

Arguments

.Object

Model object

data

Input data of class data.frame.

Value

Modified NlmePmlModel object

See Also

colMapping

Examples

model <- pkmodel(columnMap = FALSE,
                 workingDir = tempdir())

model <- dataMapping(model, pkData)


Deletes a secondary parameter from the model

Description

Deletes a secondary parameter from the model

Usage

deleteSecondary(.Object, name)

## S4 method for signature 'NlmePmlModel'
deleteSecondary(.Object, name)

Arguments

.Object

An 'NlmePmlModel' object from which you want to delete a secondary parameter.

name

Name of the secondary parameter to be deleted.

Value

Depends on the specific methods

Returns the 'NlmePmlModel' object with the secondary parameter removed.

Functions


Return dose names

Description

Use to return character vector of dose point names in model object.

Usage

doseNames(model)

Arguments

model

Model object

Value

Character vector of dose names defined in model

Examples

model <- pkmodel(columnMap = FALSE,
                 workingDir = tempdir())

doses <- doseNames(model)


Directly edit PML text in model object

Description

Allows user to edit PML text in model object using internal text editor and return a new textual model containing the edited PML statements.

Usage

editModel(.Object)

Arguments

.Object

Model object

Value

Modified NlmePmlModel object

Examples


model <- pkmodel(columnMap = FALSE,
                 workingDir = tempdir())

if (FALSE) {
  # will open an additional window with the model text:
  newModel <- editModel(model)
}



Create an Emax or Imax model

Description

Use to create an Emax or Imax model

Usage

emaxmodel(
  isPopulation = TRUE,
  checkBaseline = FALSE,
  checkFractional = FALSE,
  checkInhibitory = FALSE,
  checkSigmoid = FALSE,
  data = NULL,
  columnMap = TRUE,
  modelName = "",
  workingDir = "",
  ...
)

Arguments

isPopulation

Is this a population model TRUE or individual model FALSE?

checkBaseline

Set to TRUE if the model contains a baseline response.

checkFractional

Set to TRUE to modify the default form for the model. Only applicable to models with checkBaseline = TRUE.

checkInhibitory

Set to TRUE to change the model from an Emax to an Imax model.

checkSigmoid

Set to TRUE to change the model to its corresponding signmoid form.

data

Input dataset

columnMap

If TRUE (default) column mapping arguments are required. Set to FALSE to manually map columns after defining model using colMapping.

modelName

Model name for subdirectory created for model output in current working directory.

workingDir

Working directory to run the model. Current working directory will be used if workingDir not specified.

...

Arguments passed on to emaxmodel_MappingParameters

ID

Column mapping argument for input dataset column(s) that identify individual data profiles. Only applicable to population models isPopulation = TRUE.

C

Column mapping argument that represents the input dataset column for the independent variable that is treated as a covariate during the estimation/simulation process.

EObs

Column mapping argument that represents the input dataset column for the observed drug effect (i.e., the dependent variable).

Value

NlmePmlModel object

Column mapping

Note that quoted and unquoted column names are supported. Please see colMapping.

Examples

model <- emaxmodel(data = pkpdData, ID = "ID", C = "CObs", EObs = "EObs")

model <- emaxmodel(
  checkBaseline = TRUE,
  checkFractional = TRUE,
  checkInhibitory = TRUE,
  data = pkpdData,
  ID = "ID",
  C = "CObs",
  EObs = "EObs"
)

# View PML Code
print(model)


Emax model mapping parameters

Description

Emax model mapping parameters

Usage

emaxmodel_MappingParameters(ID = NULL, C = NULL, EObs = NULL)

Arguments

ID

Column mapping argument for input dataset column(s) that identify individual data profiles. Only applicable to population models isPopulation = TRUE.

C

Column mapping argument that represents the input dataset column for the independent variable that is treated as a covariate during the estimation/simulation process.

EObs

Column mapping argument that represents the input dataset column for the observed drug effect (i.e., the dependent variable).


Main function to specify engine parameters

Description

Use to define engine parameters for model execution.

Usage

engineParams(
  model,
  sort = NULL,
  ODE = "MatrixExponent",
  rtolODE = 1e-06,
  atolODE = 1e-06,
  maxStepsODE = 50000,
  numIterations = 1000,
  method = NULL,
  stdErr = NULL,
  isCentralDiffStdErr = TRUE,
  stepSizeStdErr = NULL,
  logTransform = NULL,
  numIntegratePtsAGQ = 1,
  numIterNonParametric = 0,
  allowSyntheticGradient = FALSE,
  fastOptimization = FALSE,
  numIterMAPNP = 0,
  numRepPCWRES = 0,
  stepSizeLinearize = 0.002,
  numDigitLaplacian = 7,
  numDigitBlup = 13,
  gradTolOuter = 2e-04,
  stepTolOuter = 1e-04,
  gradTolInner = 1.71e-05,
  stepTolInner = 7.07e-08,
  refDeltaLagl = 0.001,
  mapAssist = 0,
  iSample = 300,
  iAcceptRatio = 0.1,
  impDist = "Normal",
  tDOF = 4,
  numSampleSIR = 10,
  numBurnIn = 0,
  freezeOmega = FALSE,
  MCPEM = FALSE,
  runAllIterations = FALSE,
  scramble = "Owen",
  emTolType = 0,
  emConvLen = 10,
  emConvCritVal = 5,
  stepSizePartialDeriv = 1e-05,
  numTimeStepPartialDeriv = 20
)

Arguments

model

Model object. The type of model (population or individual) is determined by the model@isPopulation slot. If model@isPopulation is TRUE, the model is treated as a population model; otherwise, it's treated as an individual model.

sort

Logical; Specifies whether to sort the input data by subject and time. If TRUE, data are sorted. If FALSE, data are not sorted. Defaults to FALSE if the model contains reset information (model@hasResetInfo = TRUE); otherwise, defaults to TRUE.

ODE

Character; Specifies the ODE solver to be used. Options are: "MatrixExponent", "DVERK", "DOPRI5", "AutoDetect", "Stiff", "LSODE". See Details section for a description of each solver.

rtolODE

Numeric; Specifying relative tolerance for the numerical ODE solver.

atolODE

Numeric; Specifying absolute tolerance for the numerical ODE solver.

maxStepsODE

Numeric; Specifies the maximum number of steps allowed for the ODE solver.

numIterations

Integer; Specifies the maximum number of iterations for the estimation algorithm. Must be a non-negative integer, with a maximum value of 10000.

method

Character; Specifies the estimation method. For population models, options are: "QRPEM", "IT2S-EM", "FOCE-LB", "FO", "FOCE-ELS", "Laplacian", and "Naive-Pooled". For individual models, only "Naive-Pooled" is available. The default for population models depends on model characteristics:

  • If the model includes discontinuous observed variables (e.g., count data), Below Quantifiable Limit (BQL) data, or has no unfrozen sigmas, the default is "Laplacian".

  • Otherwise, the default is "FOCE-ELS".

stdErr

Character; Specifies the method for standard error computations. Options vary depending on the model type and estimation method:

  • Individual models: "Hessian" (default) or "None".

  • Population models with method = "QRPEM": "Fisher-Score" (default) or "None".

  • Population models with method = "IT2S-EM": "None" only.

  • Population models with method in c("FOCE-LB", "FO", "FOCE-ELS", "Laplacian", "Naive-Pooled"): "Sandwich" (default), "Hessian", "Fisher-Score", "Auto-Detect", or "None".

"None" means that standard error calculations are not performed.

isCentralDiffStdErr

Logical; If TRUE (default), uses central difference for standard error calculations when applicable. If FALSE, uses forward difference.

stepSizeStdErr

Numeric; Specifies the relative step size used for the numerical computation of the Hessian matrix during standard error calculations. If not specified, a default value is used (0.001 for "Naive-Pooled" method, and 0.01 otherwise).

logTransform

Logical or NULL; Controls log-transformation behavior, particularly for models with a LogAdditive residual error (e.g., C*exp(epsilon)). The internal engine parameter 'logtran' is set based on this argument and specific model characteristics as detailed below.

  • NULL (default) or TRUE: When the model has exactly one residual error model and it is LogAdditive, this setting enables Log-Transform Both Sides (LTBS). In LTBS, predictions and observations are log-transformed, and the model is fit in the log-domain. This results in the internal 'logtran' engine parameter being set to 1.

  • FALSE: When the model has exactly one residual error model and it is LogAdditive, this setting results in the LogAdditive error being treated as a proportional/multiplicative error during fitting (by neglecting third and higher-order terms in the Taylor expansion of exp(epsilon)). This sets the internal 'logtran' engine parameter to 0. For simulation, the error is treated as exp(epsilon).

For other model configurations, the 'logtran' parameter is determined as follows:

  • If there are multiple residual error models or no residual error models, 'logtran' is set to 0, irrespective of the 'logTransform' value. (In the case of multiple errors, any LogAdditive errors present are treated as proportional).

  • If there is a single residual error model that is not LogAdditive:

    • For built-in models: 'logtran' is set to 0.

    • For textual models: 'logtran' reflects the 'logTransform' setting (it becomes 1 if 'logTransform' is 'NULL' or 'TRUE', and 0 if 'logTransform' is 'FALSE'). A warning is issued if 'logTransform' is 'NULL' or 'TRUE' in this scenario, highlighting that LTBS is typically for LogAdditive errors and that error type identification can be challenging in textual models.

numIntegratePtsAGQ

Integer; Specifies the number of quadrature points per dimension to use for Adaptive Gaussian Quadrature (AGQ). Only applicable to population models when method is "FOCE-ELS" or "Laplacian".

  • 1: Standard FOCE-ELS/LAPLACIAN computation (no AGQ).

  • >1: AGQ is performed. The total number of quadrature points used is (number of ETAs)^numIntegratePtsAGQ.

numIterNonParametric

Integer; Controls non-parametric (NP) optimization.

  • 0: Disables NP optimization.

  • 1: Enables NONMEM-style NP optimization using posthoc estimates as support points.

  • >1: Enables an evolutionary NP algorithm, using numIterNonParametric as the number of generations.

Only applicable to population models when method is not "Naive-Pooled".

allowSyntheticGradient

Deprecated.

fastOptimization

Logical; Controls the differentiation method used during the optimization of random effects (etas). If TRUE, automatic differentiation is used where possible. If FALSE, a finite difference approach is used. Only applicable to population models when method is "FOCE-ELS" or "Laplacian".

numIterMAPNP

Integer; Specifies the number of iterations for a preliminary Naive-Pooled (NP) optimization run before the main estimation. Applicable when the method is not "NAIVE-POOLED".

numRepPCWRES

Integer; Specifies the number of replicates to generate for Population Conditional Weighted Residuals (PCWRES) calculations. Setting this value to 0 disables PCWRES computation. Only applicable to population models when method is not set to "Naive-Pooled".

stepSizeLinearize

Numeric; Specifies the relative step size for numerical differentiation during model linearization.

numDigitLaplacian

Numeric; Specifies the optimization accuracy (NDIGIT) for the outer loop (thetas and sigmas) when using "FOCE-ELS" or "Laplacian" methods. Only applicable to population models.

numDigitBlup

Numeric; Specifies the optimization accuracy (NDIGIT) for the inner loop (optimization of etas). Also applies to the single optimization loop in the "NAIVE-POOLED" method.

gradTolOuter

Numeric; maximum gradient tolerance for the outer loop (Theta/Omega/Sigma optimization) of "FOCE-ELS" or "Laplacian" method. This tolerance controls how close the gradient must be to zero before the outer optimization is considered converged.

stepTolOuter

Numeric; maximum step tolerance for the outer loop (Theta/Omega/Sigma optimization) of "FOCE-ELS" or "Laplacian" method. This measures the relative change in the solution vector between iterations.

gradTolInner

Numeric; maximum gradient tolerance for the inner loop (Eta optimization) of "FOCE-ELS" or "Laplacian" method. A smaller value forces the algorithm to iterate until a very small gradient is achieved.

stepTolInner

Numeric; maximum step tolerance for the inner loop (Eta optimization) of "FOCE-ELS" or "Laplacian" method. This determines when the algorithm will terminate based on minimal changes in the solution vector.

refDeltaLagl

Numeric; tolerance for the change in the log-likelihood (LL) value during outer loop optimization of "FOCE-ELS" or "Laplacian" method. This parameter is used to check convergence by comparing the absolute change in LL between major iterations. If the change in LL is less than refDeltaLagl and the optimization driver returns a specific termination code, the algorithm considers the solution sufficiently converged. This tolerance helps to avoid unnecessary iterations when improvements in LL become marginal.

mapAssist

Numeric; Controls the use of MAP assistance in the QRPEM algorithm.

  • 0: No MAP assistance.

  • >0: The inner ETAs optimization loop is used in the QRPEM outer optimization loop with a periodicity equal to the value of mapAssist.

Only applicable to population models with method = "QRPEM".

iSample

Numeric; Specifies the number of sample points used in the QRPEM algorithm. Only applicable to population models with method = "QRPEM".

iAcceptRatio

Numeric; Specifies the acceptance ratio used in the QRPEM algorithm for scaling the covariance matrix. Only applicable to population models with method = "QRPEM".

impDist

Character; Specifies the importance sampling distribution used in the QRPEM algorithm. Options are: "Normal", "DoubleExponential", "Direct", "T", "Mixture-2", "Mixture-3". Only applicable to population models with method = "QRPEM". See Details for further information.

tDOF

Numeric; Specifies the degrees of freedom for the multivariate T distribution used in importance sampling. Only applicable when method = "QRPEM" and impDist = "T". Must be between 3 and 30.

numSampleSIR

Numeric; Specifies the number of samples per eta per subject used in the Sampling Importance Resampling (SIR) algorithm within QRPEM. Only applicable to population models with method = "QRPEM".

numBurnIn

Numeric; Specifies the number of burn-in iterations in the QRPEM algorithm. During burn-in, omegas can be frozen (see freezeOmega parameter). Only applicable to population models with method = "QRPEM".

freezeOmega

Logical; Set to TRUE to freeze Omega but not Theta for the number of iterations specified in the numBurnIn. Only applicable to population models with method = "QRPEM".

MCPEM

Logical; Controls the sampling method used in the QRPEM algorithm.

  • FALSE: Quasi-Random sampling.

  • TRUE: Monte-Carlo sampling.

Only applicable to population models with method = "QRPEM".

runAllIterations

Logical; Set to TRUE to execute all requested iterations specified in numIterations. Only applicable to population models with method = "QRPEM".

scramble

Character; Specifies the scrambling method for quasi-random number generation in the QRPEM algorithm. Options are: "None", "Owen", "Faure-Tezuka". Only applicable to population models with method = "QRPEM".

emTolType

Numeric; QRPEM convergence check type. Options:

  • 0: Default (no rollout, LL & Theta and Sigma).

  • 1: LL & All Population Params (Theta, Omega, and Sigma) with rollout.

  • 2: LL with rollout.

  • 3: All Population Params with rollout.

Only applicable to population models with method = "QRPEM".

emConvLen

Numeric; number of iterations over which convergence is checked in the QRPEM method. Only applicable to population models with method = "QRPEM" and emTolType being nonzero.

emConvCritVal

Numeric; critical value used in the QRPEM convergence check. It specifies the threshold improvement required to continue iterating. Only applicable to population models with method = "QRPEM" and emTolType being nonzero.

stepSizePartialDeriv

Numeric; Specifying the step size used to numerically calculate the partial derivatives of observed variables with respect to parameters. Only applicable to individual models.

numTimeStepPartialDeriv

Numeric; Specifying the number of time steps used to output the partial derivatives of observed variables with respect to parameters. Only applicable to individual models.

Details

Both "DVERK" and "DOPRI5" are non-stiff solvers. "AutoDetect" represents LSODA solver implemenation, which solves the initial value problem for stiff or nonstiff systems of first order ordinary differential equations. "Stiff" is a LSODE (Livermore solver). It is best suited for stiff problems. "MatrixExponent" is a matrix exponential solver.

For the QRPEM method, the impDist parameter controls the importance sampling distribution. The ximpsampdof slot in the internal NlmeEngineExtraParams object is set based on impDist as follows:

Value

List of engine parameters to be used during fitting or simulation


Return extra dose lines

Description

Use to return extra dose lines for model object

Usage

extraDoseLines(model)

Arguments

model

Model object

Value

List of extra dose information

Examples

data <- pkData
data$II <- 24
data$ADDL <- 1

model <-
pkmodel(
  parameterization = "Clearance",
  numCompartments = 2,
  data = data,
  ID = "Subject",
  Time = "Act_Time",
  A1 = "Amount",
  CObs = "Conc",
  workingDir = tempdir())
addDoseCycle(
  model,
  name = "A1",
  amount = 30000,
  II = 24,
  type = "ADDL",
  colName = "ADDL")

extraDoseLines(model)


Return extra dose names

Description

Use to return extra dose names for model object

Usage

extraDoseNames(model)

Arguments

model

Model object

Value

Character vector of extra dose names

Examples

data <- pkData
data$II <- 24
data$ADDL <- 1

model <-
pkmodel(
  parameterization = "Clearance",
  numCompartments = 2,
  data = data,
  ID = "Subject",
  Time = "Act_Time",
  A1 = "Amount",
  CObs = "Conc",
  workingDir = tempdir())
addDoseCycle(
  model,
  name = "A1",
  amount = 30000,
  II = 24,
  type = "ADDL",
  colName = "ADDL")

extraDoseNames(model)


extract files used for powershell script

Description

Use for extraction of the NLME files from mmdl file.

Usage

extract_mmdl(
  mmdlfile,
  directoryToExtract,
  dataFileName = "data1.txt",
  mdlOutput = "test.mdl",
  cols1Output = "cols1.txt",
  nlmeargsOutput = "nlmeargs.txt"
)

Arguments

mmdlfile

The metamodel file path; relative paths are acceptable.

directoryToExtract

The directory where the files should be stored If missing, current working directory is used.

dataFileName

the name of the data file If missing, the default file name 'data1.txt' is used to prepare nlmeargsOutput file

mdlOutput

the name of the file to output PML code If missing, the default file name 'test.mdl' is used.

cols1Output

the name of the file to output columns defintion If missing, the default file name 'cols1.txt' is used.

nlmeargsOutput

the name of the file to output engine parameters If missing, the default file name 'nlmeargs.txt' is used.

Details

mdlOutput, dataFileName, cols1Output, nlmeargsOutput files are extracted into the folders, the names of the folders are built as ⁠{Number of estimation/simulation block in metamodel}⁠- ⁠{'est' for estimation block/'sim' for simulation block}⁠. All estimation blocks are going first irrespective of the simulation blocks presence, all simulation blocks are going next.

Value

The results of create_model_from_metamodel() run are returned.

See Also

create_model_from_metamodel()

Examples


# path to metamodel should be specified, all other arguments set to default
extract_mmdl(system.file("extdata/mmdlNoTime", "test.mmdl",
                              package = "Certara.RsNLME"),
             directoryToExtract = tempdir())



Executes an NLME simple estimation

Description

Executes an NLME simple estimation

Usage

fitmodel(
  model,
  hostPlatform = NULL,
  params,
  simpleTables,
  runInBackground = FALSE,
  filesToReturn = "*",
  ...
)

Arguments

model

PK/PD model class object.

hostPlatform

Host definition for model execution. See hostParams. If missing, PhoenixMPIDir64 is given and MPI is installed, MPI local host with 4 threads is used. If MPI is not found, local host without parallelization is used.

params

Engine parameters. See engineParams. If missing, default parameters generated by engineParams(model) are used.

simpleTables

Optional list of simple tables. See tableParams. By default a table named 'posthoc.csv' is returned with structural parameters values for all source data rows.

runInBackground

Set to TRUE to run in background and return prompt.

filesToReturn

Used to specify which files to be outputted to the model directory and loaded as returned value. By default, all the applicable files listed in the Value section will be outputted to the model directory and loaded as returned value. Only those files listed in the Value section can be specified. Simple regex patterns are supported for the specification.

...

Additional arguments for hostParams or arguments available inside engineParams functions. If engineParams arguments are supplied through both params argument and additional argument (i.e., ellipsis), then the arguments in params will be ignored and only the additional arguments will be used with warning. If hostParams arguments are supplied through both the hostPlatform argument and the ellipses, values supplied to hostPlatform will be overridden by additional arguments supplied via the ellipses e.g., ....

Value

if runInBackground is FALSE, a list with main resulted dataframes is returned:

nlme7engine.log textual output is returned and loaded with the main information related to fitting. dmp.txt structure with the results of fitting (including LL by subject information) is returned and loaded. These 2 files are returned and loaded irrespective of filesToReturn argument value.

For individual models, additional dataframe with partial derivatives is returned:

For population models and the method specified is NOT Naive-Pooled, additional dataframes are returned:

If standard error computation was requested and it was successful, additional dataframes are returned:

If nonparametric method was requested (numIterNonParametric > 0) and the method specified in engineParams is NOT Naive-Pooled, additional dataframes are returned:

if runInBackground is TRUE, only current status of job is returned.

filesToReturn with Certara.Xpose.NLME

If filesToReturn is used and "ConvergenceData.csv" and "residuals.csv" are not in the patterns, these files won't be returned and loaded. These files are essential for Certara.Xpose.NLME::xposeNlmeModel and Certara.Xpose.NLME::xposeNlme functions. This makes impossible to use the resulted object in Certara.Xpose.NLME functions.

Non-loaded but returned files

The non-loaded but returned files in the model working directory are:

See Also

tableParams, hostParams, engineParams

Examples



 # Define the host
 host <- hostParams(sharedDirectory = tempdir(),
                    parallelMethod = "None",
                    hostName = "local",
                    numCores = 1)
 # Define the model
 model <- pkmodel(numComp = 2,
                  absorption = "FirstOrder",
                  ID = "Subject",
                  Time = "Act_Time",
                  CObs = "Conc",
                  Aa = "Amount",
                  data = pkData,
                  modelName = "PkModel",
                  workingDir = tempdir())

 Table01 <- tableParams(name = "SimTableObs.csv",
                        timesList = "0,1,2,4,4.9,55.1,56,57,59,60",
                        variablesList = "C, CObs",
                        timeAfterDose = FALSE,
                        forSimulation = FALSE)

 # Update fixed effects
 model <- fixedEffect(model,
                     effect = c("tvV", "tvCl", "tvV2", "tvCl2"),
                     value = c(16, 41, 7, 14))

 # Define the engine parameters
 params <- engineParams(model)
 # Fit model
 res <- fitmodel(model = model,
                 hostPlatform = host,
                 params = params,
                 simpleTables = Table01)



Specifies the initial values, lower bounds, upper bounds, and units for fixed effects in a model

Description

Specifies the initial values, lower bounds, upper bounds, and units for fixed effects in a model

Usage

fixedEffect(
  .Object,
  effect,
  value = NULL,
  lowerBound = NULL,
  upperBound = NULL,
  isFrozen = NULL,
  unit = NULL
)

Arguments

.Object

Model object in which to define fixed effects values

effect

Character or character vector specifying names of fixed effects

value

Numeric or numeric vector specifying the initial values of fixed effects. If supplying vector, must be in the same order/length as corresponding effect.

lowerBound

Numeric or numeric vector specifying the lower limit values of fixed effects. If supplying vector, must be in the same order as effect.

upperBound

Numeric or numeric vector specifying the upper limit values of fixed effects. If supplying vector, must be in the same order as effect.

isFrozen

Logical or logical vector. Set to TRUE to freeze the fixed effect to the specified initial value. If supplying vector, must be in the same order as effect.

unit

Character or character vector specifying units of measurement for the fixed effects. If supplying a vector, must be in the same order as effect.

Value

Modified NlmePmlModel object

Examples

model <- pkmodel(
  numCompartments = 2,
  data = pkData,
  ID = "Subject",
  Time = "Act_Time",
  A1 = "Amount",
  CObs = "Conc",
  modelName = "TwCpt_IVBolus_FOCE_ELS",
  workingDir = tempdir()
  )

 # View initial/current fixed effect values
 initFixedEffects(model)

model <-
fixedEffect(
  model,
  effect = c("tvV", "tvCl", "tvV2", "tvCl2"),
  value = c(15, 5, 40, 15)
  )


Generates PML statements based on the current model

Description

Generates PML statements based on the current model

Usage

generatePML(.Object)

Arguments

.Object

PK/PD Model


Return random effect names in model

Description

Use to return character vector of random effect names (if available) in model object

Usage

getRandomEffectNames(model)

Arguments

model

Model object

Value

Characters vector of random effect names

Examples

model <- pkmodel(columnMap = FALSE,
                 workingDir = tempdir())
getRandomEffectNames(model)


Return theta names and values

Description

Returns named character vector of theta values by parsing PML fixed effect statements

Usage

getThetas(model)

Arguments

model

PK/PD model

Value

Character vector of theta names defined in model

Examples


model <- emaxmodel(
  checkBaseline = TRUE,
  checkFractional = TRUE,
  checkInhibitory = TRUE,
  data = pkpdData,
  ID = "ID",
  C = "CObs",
  EObs = "EObs"
)
getThetas(model)


Create an NLME Parallel Host Configuration

Description

This helper function simplifies the creation and configuration of an NlmeParallelHost object, which defines the environment for running NLME jobs.

Usage

hostParams(
  sharedDirectory,
  installationDirectory = Sys.getenv("INSTALLDIR"),
  hostName = Sys.info()[["nodename"]],
  machineName = "127.0.0.1",
  hostType = Sys.info()[["sysname"]],
  numCores = 4,
  parallelMethod = "LOCAL_MPI",
  userName = "",
  privateKeyFile = NULL,
  userPassword = "",
  scriptPath = "",
  rLocation = "",
  isLocal = TRUE
)

Arguments

sharedDirectory

character. The directory where temporary run folders are created. Defaults to the current working directory.

installationDirectory

character. The directory containing NLME libraries/scripts. Defaults to the INSTALLDIR environment variable.

hostName

character. A display name for the host. Defaults to the system's network name (from Sys.info()[["nodename"]]).

machineName

character. The IP address or network name of the host. Defaults to "127.0.0.1".

hostType

character. The host operating system. Defaults to the current OS (Sys.info()[["sysname"]]). While "windows" or "linux" are valid, for remote Linux hosts the following are officially supported: "RHEL" (for RHEL 8 and 9) and "UBUNTU" (for Ubuntu 22.04 and 24.04). Specifying one of these values correctly sets the PML_BIN_DIR variable.

numCores

numeric. The number of CPU cores to utilize. Defaults to 4.

parallelMethod

character. The parallel execution method. Options include: "None", "Multicore", "LOCAL_MPI", "SGE", "SGE_MPI", "TORQUE", "TORQUE_MPI", "LSF", "LSF_MPI", "SLURM", "SLURM_MPI". Defaults to "LOCAL_MPI".

userName

character. The username for remote host authentication.

privateKeyFile

character. The path to an SSH private key file for remote authentication. See ssh::ssh_connect() for more details.

userPassword

character or function. The password or a callback function for remote authentication. See ssh::ssh_connect() for details.

scriptPath

character. The path to a script to run on a remote host before the main job starts. Ignored for local runs.

rLocation

character. The path to the Rscript executable on a remote host. Ignored for local runs.

isLocal

logical. Set to TRUE for a local host or FALSE for a remote host. Defaults to TRUE.

Value

An NlmeParallelHost object configured with the specified parameters.

Examples

host <- hostParams(sharedDirectory = tempdir(),
                   parallelMethod = "LOCAL_MPI",
                   hostName = "Local",
                   numCores = 4)


Display/Set initial estimates for fixed effects

Description

Display/Set initial estimates for fixed effects

Usage

initFixedEffects(.Object)

## S4 method for signature 'NlmePmlModel'
initFixedEffects(.Object)

initFixedEffects(.Object) <- value

## S4 replacement method for signature 'NlmePmlModel'
initFixedEffects(.Object) <- value

Arguments

.Object

PK/PD model

value

Named numeric vector

Value

Named numeric vector of fixed effects estimates

See Also

fixedEffect

Examples

model <- pkmodel(
  numCompartments = 2,
  data = pkData,
  ID = "Subject",
  Time = "Act_Time",
  A1 = "Amount",
  CObs = "Conc",
  modelName = "TwCpt_IVBolus_FOCE_ELS",
  workingDir = tempdir()
  )

# View initial/current fixed effect values
 initFixedEffects(model)

# May also use as a 'replacement function' to set the values
initFixedEffects(model) <- c(tvV = 15, tvCl = 5, tvV2 = 40, tvCl2 = 15)


Create linear model

Description

Use to create a constant, linear, or quadratic PD model

Usage

linearmodel(
  isPopulation = TRUE,
  type = "Constant",
  data = NULL,
  columnMap = TRUE,
  modelName = "",
  workingDir = "",
  ...
)

Arguments

isPopulation

Is this a population model TRUE or individual model FALSE?

type

Model type. Options are "Constant", "Linear", "Quadratic".

data

Input dataset

columnMap

If TRUE (default) column mapping arguments are required. Set to FALSE to manually map columns after defining model using colMapping.

modelName

Model name for subdirectory created for model output in current working directory.

workingDir

Working directory to run the model. Current working directory will be used if workingDir not specified.

...

Arguments passed on to linearmodel_MappingParameters

ID

Column mapping argument for input dataset column(s) that identify individual data profiles. Only applicable to population models isPopulation = TRUE.

C

Column mapping argument that represents the input dataset column for the independent variable that is treated as a covariate during the estimation/simulation process.

EObs

Column mapping argument that represents the input dataset column for the observed drug effect (i.e., the dependent variable).

Value

NlmePmlModel object

Column mapping

Note that quoted and unquoted column names are supported. Please see colMapping.

Examples

model <- linearmodel(type = "Linear", data = pkpdData, ID = "ID", C = "CObs", EObs = "EObs")

# View PML Code
print(model)


Linear model mapping parameters

Description

Linear model mapping parameters

Usage

linearmodel_MappingParameters(ID = NULL, C = NULL, EObs = NULL)

Arguments

ID

Column mapping argument for input dataset column(s) that identify individual data profiles. Only applicable to population models isPopulation = TRUE.

C

Column mapping argument that represents the input dataset column for the independent variable that is treated as a covariate during the estimation/simulation process.

EObs

Column mapping argument that represents the input dataset column for the observed drug effect (i.e., the dependent variable).


Lists covariate effect names in the model

Description

This function lists the names of covariate effects in a provided pharmacokinetic/pharmacodynamic (PK/PD) model.

Usage

listCovariateEffectNames(.Object)

## S4 method for signature 'NlmePmlModel'
listCovariateEffectNames(.Object)

Arguments

.Object

PK/PD model

Value

A vector of character strings containing the names of the covariate effects in the model.

Examples


model <- pkmodel(
  numCompartments = 2,
  data = pkData,
  ID = "Subject",
  Time = "Act_Time",
  A1 = "Amount",
  CObs = "Conc",
  workingDir = tempdir()
)
model <- addCovariate(model,
  covariate = "Gender",
  type = "Categorical",
  effect = c("V2", "Cl2"),
  levels = c(0, 1),
  labels = c("Female", "Male")
)
listCovariateEffectNames(model)


Load model.rda file

Description

Loads a previously saved model from disk.

Usage

loadModel(directory)

Arguments

directory

Directory where the model was saved

Details

Note, the names of model, engine, and host objects will be appended with name of model directory when reloading model.rda file to global environment.

Value

No value is returned. Model object is loaded in global environment.

Examples


TempDir <- tempdir()
model <- emaxmodel(
  checkBaseline = TRUE,
  checkFractional = TRUE,
  checkInhibitory = TRUE,
  data = pkpdData,
  ID = "ID",
  C = "CObs",
  EObs = "EObs",
  modelName = "model",
  workingDir = TempDir
)

saveModel(model)

loadModel(TempDir)



Return model variable names

Description

Return a vector of model variable names from model object

Usage

modelVariableNames(model)

Arguments

model

Model object

Value

Character vector of required model variable names

Examples


model <- pkmodel(columnMap = FALSE,
                 workingDir = tempdir())
modelVariableNames(model)



Get observation names

Description

Get observation model variables names.

Usage

observationNames(model)

Arguments

model

Model object

Value

Character vector of observation model variables names.

Examples

model <- pkemaxmodel(columnMap = FALSE)
obsnames <- observationNames(model)


Obtain NLME License

Description

This function attempts to authenticate and obtain an NLME license using the specified installation directory and licensing tool.

Usage

obtain_NLMELicense(
  InstallDir = Sys.getenv("INSTALLDIR"),
  ForceAuth = FALSE,
  ForceLicenseGet = FALSE,
  verbose = getOption("verbose")
)

Arguments

InstallDir

A character string specifying the directory where the NLME Engine is installed e.g., INSTALLDIR environment variable. The cadlicensingtool executable is expected to be located within this directory, or within a subdirectory specified by the PML_BIN_DIR environment variable.

ForceAuth

A logical value indicating whether to force re-authentication even if already authenticated. Default is FALSE.

ForceLicenseGet

A logical value indicating whether to force obtaining the license even if already licensed. Default is FALSE.

verbose

A logical value indicating whether to print verbose output. Default is getOption("verbose").

Details

This function checks for the presence of the necessary appsettings.json file as indicated by the CAD_CONFIG_FILE environment variable, runs the licensing tool to authenticate the user, and attempts to obtain an NLME license. It prints detailed messages if the verbose parameter is set to TRUE.

Value

A logical value indicating whether the license was successfully obtained.

Examples


INSTALLDIR <- Sys.getenv("INSTALLDIR")
if (INSTALLDIR == "") INSTALLDIR <- "C:/Program Files/Certara/NLME_Engine"
result <- obtain_NLMELicense(INSTALLDIR, verbose = TRUE)
if (result) {
  message("License obtained successfully!")
} else {
  message("Failed to obtain license.")
}


Embed column definition info into the model

Description

Add/update column definition information for the model object

Usage

parsePMLColMap(.Object, ForceRun = TRUE)

Arguments

.Object

Model (NlmePmlModel) object

ForceRun

Set to TRUE to force run

Details

Intended to be used by other packages

Value

modified NLMEPmlModel object with column mapping definitions


Create NlmeParallelHost object from json file with host definition

Description

Create NlmeParallelHost object from json file with host definition

Usage

parse_NLMEHosts(nlme_hostPath)

Arguments

nlme_hostPath

json file with host definition for model execution. See NlmeParallelHost class definition. If missing, MPI local host with 4 threads is used for simple estimation mode, multicore host is used for the others.

Value

the NlmeParallelHost class object is returned.

Examples


# path nlme_hostPath should be specified
 nlme_hostPath <- tempfile()
 host1 <- paste0('{"profile_name":"Multicore",',
  '"hostname":"127.0.0.1",',
  '"cores_number":4,',
  '"parallel_mode":"MULTICORE"}')
 host2 <- paste0('{"profile_name":"MPI",',
 '"hostname":"127.0.0.1",',
 '"cores_number":8,',
 '"parallel_mode":"LOCAL_MPI"}')

writeLines(paste0("[", host1, ",", host2, "]"), nlme_hostPath)
hosts <- parse_NLMEHosts(nlme_hostPath)


Pharmacokinetic dataset containing 16 subjects with single bolus dose

Description

Pharmacokinetic dataset containing 16 subjects with single bolus dose.

Usage

pkData

Format

A data frame with 112 rows and 8 variables:

Subject

Subject ID

Nom_Time

Nominal Time

Act_Time

Actual Time

Amount

Amount of dose

Conc

Observations of drug concentration in blood

Age

Age

BodyWeight

Body weight

Gender

Gender ("male", "female")

Source

Certara University


Pharmacokinetic pediatric dataset containing 80 subjects with single bolus dose.

Description

Pharmacokinetic pediatric dataset containing 80 subjects with single bolus dose. Dataset includes covariates and observations Below Quantification Limit (BQL).

Usage

pkcovbqlData

Format

A data frame with 880 rows and 8 variables:

ID

Subject ID

Time

Nominal Time

Dose

Amount of dose

CObs

Observations of drug concentration in blood

LLOQ

Lower Limit of Quantification

CObsBQL

Variable that indicates whether the observed drug concentration is below the limit of quantification

BW

Body weight

PMA

Postmenstrual age

Source

The data is simulated using a one-compartment model with IV bolus, where the central volume is allometric weight scaled, and the clearance is scaled by a combination of allometric weight scaling and a sigmoidal maturation function driven by PMA. Germovsek E., et al, Pharmacokinetic–Pharmacodynamic Modeling in Pediatric Drug Development, and the Importance of Standardized Scaling of Clearance, Clin Pharmacokinet (2019) 58:39–52.


Create a PK/Emax or PK/Imax model

Description

Use to create a PK/Emax or PK/Imax model

Usage

pkemaxmodel(
  isPopulation = TRUE,
  parameterization = "Clearance",
  absorption = "Intravenous",
  numCompartments = 1,
  isClosedForm = TRUE,
  isTlag = FALSE,
  hasEliminationComp = FALSE,
  isFractionExcreted = FALSE,
  isSaturating = FALSE,
  infusionAllowed = FALSE,
  isDuration = FALSE,
  isSequential = FALSE,
  isPkFrozen = FALSE,
  hasEffectsCompartment = FALSE,
  checkBaseline = FALSE,
  checkFractional = FALSE,
  checkInhibitory = FALSE,
  checkSigmoid = FALSE,
  isEmaxFrozen = FALSE,
  data = NULL,
  columnMap = TRUE,
  modelName = "",
  workingDir = "",
  ...
)

Arguments

isPopulation

Is this a population model TRUE or individual model FALSE?

parameterization

Type of parameterization. Options are "Clearance", "Micro", "Macro", or "Macro1".

absorption

Type of absorption. Options are "Intravenous", "FirstOrder", "Gamma", "InverseGaussian", "Weibull" .

numCompartments

Value of either 1, 2, or 3.

isClosedForm

Set to TRUE to convert model from a differential equation to close form.

isTlag

Set to TRUE to add a lag time parameter to the model.

hasEliminationComp

Set to TRUE to add an elimination compartment to the model.

isFractionExcreted

Set to TRUE if elimination compartment (hasEliminationComp = TRUE) contains a fraction excreted parameter.

isSaturating

Set to TRUE to use Michaelis-Menten kinetics for elimination. Only applicable to models with paramteterization = "Clearance"

infusionAllowed

Set to TRUE if infusions allowed.

isDuration

Set to TRUE if infusions use duration instead of rate (must also set infusionAllowed = TRUE).

isSequential

Set to TRUE to freeze PK fixed effects and convert the corresponding random effects into covariates as well as remove the PK observed variable from the model.

isPkFrozen

Set to TRUE to freeze PK fixed effects and remove the corresponding random effects as well as the PK observed variable from the model.

hasEffectsCompartment

Set to TRUE to include an effect compartment into the model.

checkBaseline

Does Emax/Imax model have a baseline response?

checkFractional

Set to TRUE to modify the default form for the Emax/Imax model. Only applicable to models with checkBaseline = TRUE.

checkInhibitory

Set to TRUE to change the default Emax to Imax model.

checkSigmoid

Set to TRUE to change the Emax/Imax to its corresponding sigmoid form.

isEmaxFrozen

Set to TRUE to freeze PD fixed effects and remove the corresponding random effects as well as the PD observed variable from the model.

data

Input dataset

columnMap

If TRUE (default) column mapping arguments are required. Set to FALSE to manually map columns after defining model using colMapping.

modelName

Model name for subdirectory created for model output in current working directory.

workingDir

Working directory to run the model. Current working directory will be used if workingDir not specified.

...

Arguments passed on to pkindirectmodel_MappingParameters

ID

Column mapping argument for input dataset column(s) that identify individual data profiles. Only applicable to population models isPopulation = TRUE.

Time

Column mapping argument that represents the input dataset column for the relative time used in a study and only applicable to time-based models.

A1

Column mapping argument that represents the input dataset column for the amount of drug administered. Only applicable to the following types of models:

  • Models with absorption = "Intravenous" and parameterization set to either "Clearance","Micro", or "Macro"

  • Models with absorption set to either "Gamma", "InverseGaussian", or "Weibull"

Aa

Column mapping argument that represents the input dataset column for the amount of drug administered and only applicable to models with absorption = "FirstOrder".

A

Column mapping argument that represents the input dataset column for the amount of drug administered and only applicable to models with absorption = "Intravenous" and parameterization = "Macro1".

A1_Rate

Column mapping argument that represents the input dataset column for the rate of drug administered. Only applicable to the following types of models:

  • Models with absorption = "Intravenous", infusionAllowed = TRUE and parameterization set to either "Clearance","Micro" or "Macro"

  • Models with absorption set to either "Gamma", "InverseGaussian", or "Weibull" and infusionAllowed = TRUE

A1_Duration

Column mapping argument that represents the input dataset column for the duration of drug administered. Only applicable to the following types of models:

  • Models with absorption = "Intravenous", infusionAllowed = TRUE with isDuration = TRUE and parameterization set to either "Clearance","Micro" or "Macro"

  • Models with absorption set to either "Gamma", "InverseGaussian", or "Weibull" and infusionAllowed = TRUE with isDuration = TRUE

Aa_Rate

Column mapping argument that represents the input dataset column for the rate of drug administered and only applicable to models with absorption = "FirstOrder", infusionAllowed = TRUE.

Aa_Duration

Column mapping argument that represents the input dataset column for the duration of drug administered and only applicable to models with absorption = "FirstOrder", infusionAllowed = TRUE, and isDuration = TRUE.

A_Rate

Column mapping argument that represents the input dataset column for the rate of drug administered and only applicable to models with absorption = "Intravenous", infusionAllowed = TRUE, and parameterization = "Macro1".

A_Duration

Column mapping argument that represents the input dataset column for the duration of drug administered and only applicable to models with absorption = "Intravenous", infusionAllowed = TRUE, isDuration = TRUE, and parameterization = "Macro1".

A1Strip

Column mapping argument that represents the input dataset column for the stripping dose and only applicable to models with parameterization = "Macro".

CObs

Column mapping argument that represents the input dataset column for the observations of drug concentration in the central compartment and only applicable to models with parameterization being either set to either "Clearance" or "Micro".

C1Obs

Column mapping argument that represents the input dataset column for the observations of drug concentration in the central compartment and only applicable to models with parameterization being either set to either "Macro" or "Macro1".

A0Obs

Column mapping argument that represents the input dataset column for the observed amount of drug in the elimination compartment. (hasEliminationComp = TRUE).

EObs

Column mapping argument that represents the input dataset column for the observed drug effect.

nV

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nV.

nV2

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nV2.

nV3

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nV3.

nCl

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nCl.

nCl2

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nCl2.

nCl3

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nCl3.

nKa

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nKa.

nA

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nA.

nAlpha

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nAlpha.

nB

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nB.

nBeta

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nBeta.

nC

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nC.

nGamma

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nGamma.

nKe

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nKe.

nK12

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nK12.

nK21

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nK21.

nK13

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nK13.

nK31

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nK31.

nTlag

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nTlag.

nKm

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nKm.

nVmax

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nVmax.

nFe

If isSequential = TRUE and isFractionExcreted = TRUE, mapped to the input dataset column that lists the values for random effect nFe.

nMeanDelayTime

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nMeanDelayTime.

nShapeParam

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nShapeParam.

nShapeParamMinusOne

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nShapeParamMinusOne.

Value

NlmePmlModel object

Column mapping

Note that quoted and unquoted column names are supported. Please see colMapping.

Examples

model <- pkemaxmodel(
  parameterization = "Macro",
  data = pkpdData,
  Time = "Time",
  ID = "ID",
  A1 = "Dose",
  C1Obs = "CObs",
  EObs = "EObs"
)

# View the model as well as its associated column mappings
print(model)


Create a PK/Indirect response model

Description

Use to create a PK/Indirect response model.

Usage

pkindirectmodel(
  isPopulation = TRUE,
  parameterization = "Clearance",
  absorption = "Intravenous",
  numCompartments = 1,
  isClosedForm = TRUE,
  isTlag = FALSE,
  hasEliminationComp = FALSE,
  isFractionExcreted = FALSE,
  isSaturating = FALSE,
  infusionAllowed = FALSE,
  isDuration = FALSE,
  isSequential = FALSE,
  isPkFrozen = FALSE,
  hasEffectsCompartment = FALSE,
  indirectType = "LimitedStimulation",
  isBuildup = TRUE,
  isExponent = FALSE,
  indirectFrozen = FALSE,
  data = NULL,
  columnMap = TRUE,
  modelName = "",
  workingDir = "",
  ...
)

Arguments

isPopulation

Is this a population model TRUE or individual model FALSE?

parameterization

Type of parameterization. Options are "Clearance", "Micro", "Macro", or "Macro1".

absorption

Type of absorption. Options are "Intravenous", "FirstOrder", "Gamma", "InverseGaussian", "Weibull" .

numCompartments

Value of either 1, 2, or 3.

isClosedForm

Set to TRUE to convert model from a differential equation to close form.

isTlag

Set to TRUE to add a lag time parameter to the model.

hasEliminationComp

Set to TRUE to add an elimination compartment to the model.

isFractionExcreted

Set to TRUE if elimination compartment (hasEliminationComp = TRUE) contains a fraction excreted parameter.

isSaturating

Set to TRUE to use Michaelis-Menten kinetics for elimination. Only applicable to models with paramteterization = "Clearance"

infusionAllowed

Set to TRUE if infusions allowed.

isDuration

Set to TRUE if infusions use duration instead of rate (must also set infusionAllowed = TRUE).

isSequential

Set to TRUE to freeze PK fixed effects and convert the corresponding random effects into covariates as well as remove the PK observed variable from the model.

isPkFrozen

Set to TRUE to freeze PK fixed effects and remove the corresponding random effects as well as the PK observed variable from the model.

hasEffectsCompartment

Set to TRUE to include an effect compartment into the model.

indirectType

Type of drug actions for the indirect response model. Options are "LimitedStimulation", "InfiniteStimulation", "LimitedInhibition", "InverseInhibition", "LinearStimulation", or "LogLinearStimulation".

isBuildup

Set to FALSE to have the drug actions affect the loss/degradation instead of the production.

isExponent

Set to TRUE to add an exponent parameter to the drug action term.

indirectFrozen

Set to TRUE to freeze PD fixed effects and remove the corresponding random effects as well as the PD observed variable from the model.

data

Input dataset

columnMap

If TRUE (default) column mapping arguments are required. Set to FALSE to manually map columns after defining model using colMapping.

modelName

Model name for subdirectory created for model output in current working directory.

workingDir

Working directory to run the model. Current working directory will be used if workingDir not specified.

...

Arguments passed on to pkindirectmodel_MappingParameters

ID

Column mapping argument for input dataset column(s) that identify individual data profiles. Only applicable to population models isPopulation = TRUE.

Time

Column mapping argument that represents the input dataset column for the relative time used in a study and only applicable to time-based models.

A1

Column mapping argument that represents the input dataset column for the amount of drug administered. Only applicable to the following types of models:

  • Models with absorption = "Intravenous" and parameterization set to either "Clearance","Micro", or "Macro"

  • Models with absorption set to either "Gamma", "InverseGaussian", or "Weibull"

Aa

Column mapping argument that represents the input dataset column for the amount of drug administered and only applicable to models with absorption = "FirstOrder".

A

Column mapping argument that represents the input dataset column for the amount of drug administered and only applicable to models with absorption = "Intravenous" and parameterization = "Macro1".

A1_Rate

Column mapping argument that represents the input dataset column for the rate of drug administered. Only applicable to the following types of models:

  • Models with absorption = "Intravenous", infusionAllowed = TRUE and parameterization set to either "Clearance","Micro" or "Macro"

  • Models with absorption set to either "Gamma", "InverseGaussian", or "Weibull" and infusionAllowed = TRUE

A1_Duration

Column mapping argument that represents the input dataset column for the duration of drug administered. Only applicable to the following types of models:

  • Models with absorption = "Intravenous", infusionAllowed = TRUE with isDuration = TRUE and parameterization set to either "Clearance","Micro" or "Macro"

  • Models with absorption set to either "Gamma", "InverseGaussian", or "Weibull" and infusionAllowed = TRUE with isDuration = TRUE

Aa_Rate

Column mapping argument that represents the input dataset column for the rate of drug administered and only applicable to models with absorption = "FirstOrder", infusionAllowed = TRUE.

Aa_Duration

Column mapping argument that represents the input dataset column for the duration of drug administered and only applicable to models with absorption = "FirstOrder", infusionAllowed = TRUE, and isDuration = TRUE.

A_Rate

Column mapping argument that represents the input dataset column for the rate of drug administered and only applicable to models with absorption = "Intravenous", infusionAllowed = TRUE, and parameterization = "Macro1".

A_Duration

Column mapping argument that represents the input dataset column for the duration of drug administered and only applicable to models with absorption = "Intravenous", infusionAllowed = TRUE, isDuration = TRUE, and parameterization = "Macro1".

A1Strip

Column mapping argument that represents the input dataset column for the stripping dose and only applicable to models with parameterization = "Macro".

CObs

Column mapping argument that represents the input dataset column for the observations of drug concentration in the central compartment and only applicable to models with parameterization being either set to either "Clearance" or "Micro".

C1Obs

Column mapping argument that represents the input dataset column for the observations of drug concentration in the central compartment and only applicable to models with parameterization being either set to either "Macro" or "Macro1".

A0Obs

Column mapping argument that represents the input dataset column for the observed amount of drug in the elimination compartment. (hasEliminationComp = TRUE).

EObs

Column mapping argument that represents the input dataset column for the observed drug effect.

nV

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nV.

nV2

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nV2.

nV3

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nV3.

nCl

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nCl.

nCl2

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nCl2.

nCl3

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nCl3.

nKa

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nKa.

nA

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nA.

nAlpha

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nAlpha.

nB

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nB.

nBeta

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nBeta.

nC

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nC.

nGamma

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nGamma.

nKe

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nKe.

nK12

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nK12.

nK21

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nK21.

nK13

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nK13.

nK31

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nK31.

nTlag

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nTlag.

nKm

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nKm.

nVmax

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nVmax.

nFe

If isSequential = TRUE and isFractionExcreted = TRUE, mapped to the input dataset column that lists the values for random effect nFe.

nMeanDelayTime

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nMeanDelayTime.

nShapeParam

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nShapeParam.

nShapeParamMinusOne

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nShapeParamMinusOne.

Value

NlmePmlModel object

Column mapping

Note that quoted and unquoted column names are supported. Please see colMapping.

Examples

model <- pkindirectmodel(
  parameterization = "Micro",
  data = pkpdData,
  ID = "ID",
  Time = "Time",
  A1 = "Dose",
  CObs = "CObs",
  EObs = "EObs"
)

# View PML Code
print(model)


PK Indirect model mapping parameters

Description

PK Indirect mapping parameters

Usage

pkindirectmodel_MappingParameters(
  ID = NULL,
  Time = NULL,
  A1 = NULL,
  Aa = NULL,
  A = NULL,
  A1_Rate = NULL,
  A1_Duration = NULL,
  Aa_Rate = NULL,
  Aa_Duration = NULL,
  A_Rate = NULL,
  A_Duration = NULL,
  A1Strip = NULL,
  CObs = NULL,
  C1Obs = NULL,
  A0Obs = NULL,
  EObs = NULL,
  nV = NULL,
  nV2 = NULL,
  nV3 = NULL,
  nCl = NULL,
  nCl2 = NULL,
  nCl3 = NULL,
  nKa = NULL,
  nA = NULL,
  nAlpha = NULL,
  nB = NULL,
  nBeta = NULL,
  nC = NULL,
  nGamma = NULL,
  nKe = NULL,
  nK12 = NULL,
  nK21 = NULL,
  nK13 = NULL,
  nK31 = NULL,
  nTlag = NULL,
  nKm = NULL,
  nVmax = NULL,
  nFe = NULL,
  nMeanDelayTime = NULL,
  nShapeParamMinusOne = NULL,
  nShapeParam = NULL
)

Arguments

ID

Column mapping argument for input dataset column(s) that identify individual data profiles. Only applicable to population models isPopulation = TRUE.

Time

Column mapping argument that represents the input dataset column for the relative time used in a study and only applicable to time-based models.

A1

Column mapping argument that represents the input dataset column for the amount of drug administered. Only applicable to the following types of models:

  • Models with absorption = "Intravenous" and parameterization set to either "Clearance","Micro", or "Macro"

  • Models with absorption set to either "Gamma", "InverseGaussian", or "Weibull"

Aa

Column mapping argument that represents the input dataset column for the amount of drug administered and only applicable to models with absorption = "FirstOrder".

A

Column mapping argument that represents the input dataset column for the amount of drug administered and only applicable to models with absorption = "Intravenous" and parameterization = "Macro1".

A1_Rate

Column mapping argument that represents the input dataset column for the rate of drug administered. Only applicable to the following types of models:

  • Models with absorption = "Intravenous", infusionAllowed = TRUE and parameterization set to either "Clearance","Micro" or "Macro"

  • Models with absorption set to either "Gamma", "InverseGaussian", or "Weibull" and infusionAllowed = TRUE

A1_Duration

Column mapping argument that represents the input dataset column for the duration of drug administered. Only applicable to the following types of models:

  • Models with absorption = "Intravenous", infusionAllowed = TRUE with isDuration = TRUE and parameterization set to either "Clearance","Micro" or "Macro"

  • Models with absorption set to either "Gamma", "InverseGaussian", or "Weibull" and infusionAllowed = TRUE with isDuration = TRUE

Aa_Rate

Column mapping argument that represents the input dataset column for the rate of drug administered and only applicable to models with absorption = "FirstOrder", infusionAllowed = TRUE.

Aa_Duration

Column mapping argument that represents the input dataset column for the duration of drug administered and only applicable to models with absorption = "FirstOrder", infusionAllowed = TRUE, and isDuration = TRUE.

A_Rate

Column mapping argument that represents the input dataset column for the rate of drug administered and only applicable to models with absorption = "Intravenous", infusionAllowed = TRUE, and parameterization = "Macro1".

A_Duration

Column mapping argument that represents the input dataset column for the duration of drug administered and only applicable to models with absorption = "Intravenous", infusionAllowed = TRUE, isDuration = TRUE, and parameterization = "Macro1".

A1Strip

Column mapping argument that represents the input dataset column for the stripping dose and only applicable to models with parameterization = "Macro".

CObs

Column mapping argument that represents the input dataset column for the observations of drug concentration in the central compartment and only applicable to models with parameterization being either set to either "Clearance" or "Micro".

C1Obs

Column mapping argument that represents the input dataset column for the observations of drug concentration in the central compartment and only applicable to models with parameterization being either set to either "Macro" or "Macro1".

A0Obs

Column mapping argument that represents the input dataset column for the observed amount of drug in the elimination compartment. (hasEliminationComp = TRUE).

EObs

Column mapping argument that represents the input dataset column for the observed drug effect.

nV

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nV.

nV2

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nV2.

nV3

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nV3.

nCl

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nCl.

nCl2

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nCl2.

nCl3

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nCl3.

nKa

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nKa.

nA

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nA.

nAlpha

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nAlpha.

nB

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nB.

nBeta

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nBeta.

nC

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nC.

nGamma

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nGamma.

nKe

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nKe.

nK12

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nK12.

nK21

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nK21.

nK13

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nK13.

nK31

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nK31.

nTlag

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nTlag.

nKm

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nKm.

nVmax

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nVmax.

nFe

If isSequential = TRUE and isFractionExcreted = TRUE, mapped to the input dataset column that lists the values for random effect nFe.

nMeanDelayTime

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nMeanDelayTime.

nShapeParamMinusOne

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nShapeParamMinusOne.

nShapeParam

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nShapeParam.


Create PK linear model

Description

Use to create a PK/PD model with PD described by either constant, linear, or quadratic model

Usage

pklinearmodel(
  isPopulation = TRUE,
  parameterization = "Clearance",
  absorption = "Intravenous",
  numCompartments = 1,
  isClosedForm = TRUE,
  isTlag = FALSE,
  hasEliminationComp = FALSE,
  isFractionExcreted = FALSE,
  isSaturating = FALSE,
  infusionAllowed = FALSE,
  isDuration = FALSE,
  isSequential = FALSE,
  isPkFrozen = FALSE,
  hasEffectsCompartment = FALSE,
  linearType = "Constant",
  isLinearFrozen = FALSE,
  data = NULL,
  columnMap = TRUE,
  modelName = "",
  workingDir = "",
  ...
)

Arguments

isPopulation

Is this a population model TRUE or individual model FALSE?

parameterization

Type of parameterization. Options are "Clearance", "Micro", "Macro", or "Macro1".

absorption

Type of absorption. Options are "Intravenous", "FirstOrder", "Gamma", "InverseGaussian", "Weibull" .

numCompartments

Value of either 1, 2, or 3.

isClosedForm

Set to TRUE to convert model from a differential equation to close form.

isTlag

Set to TRUE to add a lag time parameter to the model.

hasEliminationComp

Set to TRUE to add an elimination compartment to the model.

isFractionExcreted

Set to TRUE if elimination compartment (hasEliminationComp = TRUE) contains a fraction excreted parameter.

isSaturating

Set to TRUE to use Michaelis-Menten kinetics for elimination. Only applicable to models with paramteterization = "Clearance"

infusionAllowed

Set to TRUE if infusions allowed.

isDuration

Set to TRUE if infusions use duration instead of rate (must also set infusionAllowed = TRUE).

isSequential

Set to TRUE to freeze PK fixed effects and convert the corresponding random effects into covariates as well as remove the PK observed variable from the model.

isPkFrozen

Set to TRUE to freeze PK fixed effects and remove the corresponding random effects as well as the PK observed variable from the model.

hasEffectsCompartment

Set to TRUE to include an effect compartment into the model.

linearType

Type of PD model; Options are "Constant", "Linear", "Quadratic".

isLinearFrozen

Set to TRUE to freeze PD fixed effects and remove the corresponding random effects as well as the PD observed variable from the model.

data

Input dataset

columnMap

If TRUE (default) column mapping arguments are required. Set to FALSE to manually map columns after defining model using colMapping.

modelName

Model name for subdirectory created for model output in current working directory.

workingDir

Working directory to run the model. Current working directory will be used if workingDir not specified.

...

Arguments passed on to pkindirectmodel_MappingParameters

ID

Column mapping argument for input dataset column(s) that identify individual data profiles. Only applicable to population models isPopulation = TRUE.

Time

Column mapping argument that represents the input dataset column for the relative time used in a study and only applicable to time-based models.

A1

Column mapping argument that represents the input dataset column for the amount of drug administered. Only applicable to the following types of models:

  • Models with absorption = "Intravenous" and parameterization set to either "Clearance","Micro", or "Macro"

  • Models with absorption set to either "Gamma", "InverseGaussian", or "Weibull"

Aa

Column mapping argument that represents the input dataset column for the amount of drug administered and only applicable to models with absorption = "FirstOrder".

A

Column mapping argument that represents the input dataset column for the amount of drug administered and only applicable to models with absorption = "Intravenous" and parameterization = "Macro1".

A1_Rate

Column mapping argument that represents the input dataset column for the rate of drug administered. Only applicable to the following types of models:

  • Models with absorption = "Intravenous", infusionAllowed = TRUE and parameterization set to either "Clearance","Micro" or "Macro"

  • Models with absorption set to either "Gamma", "InverseGaussian", or "Weibull" and infusionAllowed = TRUE

A1_Duration

Column mapping argument that represents the input dataset column for the duration of drug administered. Only applicable to the following types of models:

  • Models with absorption = "Intravenous", infusionAllowed = TRUE with isDuration = TRUE and parameterization set to either "Clearance","Micro" or "Macro"

  • Models with absorption set to either "Gamma", "InverseGaussian", or "Weibull" and infusionAllowed = TRUE with isDuration = TRUE

Aa_Rate

Column mapping argument that represents the input dataset column for the rate of drug administered and only applicable to models with absorption = "FirstOrder", infusionAllowed = TRUE.

Aa_Duration

Column mapping argument that represents the input dataset column for the duration of drug administered and only applicable to models with absorption = "FirstOrder", infusionAllowed = TRUE, and isDuration = TRUE.

A_Rate

Column mapping argument that represents the input dataset column for the rate of drug administered and only applicable to models with absorption = "Intravenous", infusionAllowed = TRUE, and parameterization = "Macro1".

A_Duration

Column mapping argument that represents the input dataset column for the duration of drug administered and only applicable to models with absorption = "Intravenous", infusionAllowed = TRUE, isDuration = TRUE, and parameterization = "Macro1".

A1Strip

Column mapping argument that represents the input dataset column for the stripping dose and only applicable to models with parameterization = "Macro".

CObs

Column mapping argument that represents the input dataset column for the observations of drug concentration in the central compartment and only applicable to models with parameterization being either set to either "Clearance" or "Micro".

C1Obs

Column mapping argument that represents the input dataset column for the observations of drug concentration in the central compartment and only applicable to models with parameterization being either set to either "Macro" or "Macro1".

A0Obs

Column mapping argument that represents the input dataset column for the observed amount of drug in the elimination compartment. (hasEliminationComp = TRUE).

EObs

Column mapping argument that represents the input dataset column for the observed drug effect.

nV

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nV.

nV2

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nV2.

nV3

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nV3.

nCl

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nCl.

nCl2

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nCl2.

nCl3

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nCl3.

nKa

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nKa.

nA

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nA.

nAlpha

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nAlpha.

nB

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nB.

nBeta

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nBeta.

nC

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nC.

nGamma

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nGamma.

nKe

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nKe.

nK12

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nK12.

nK21

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nK21.

nK13

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nK13.

nK31

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nK31.

nTlag

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nTlag.

nKm

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nKm.

nVmax

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nVmax.

nFe

If isSequential = TRUE and isFractionExcreted = TRUE, mapped to the input dataset column that lists the values for random effect nFe.

nMeanDelayTime

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nMeanDelayTime.

nShapeParam

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nShapeParam.

nShapeParamMinusOne

If isSequential = TRUE, mapped to the input dataset column that lists the values for random effect nShapeParamMinusOne.

Value

NlmePmlModel object

Column mapping

Note that quoted and unquoted column names are supported. Please see colMapping.

Examples

model <- pklinearmodel(
  parameterization = "Clearance",
  linearType = "Constant",
  data = pkpdData,
  ID = "ID",
  Time = "Time",
  A1 = "Dose",
  CObs = "CObs",
  EObs = "EObs"
)

# View the model as well as its associated column mappings
print(model)


Creates a PK model

Description

Use to create a PK model

Usage

pkmodel(
  isPopulation = TRUE,
  parameterization = "Clearance",
  absorption = "Intravenous",
  numCompartments = 1,
  isClosedForm = TRUE,
  isTlag = FALSE,
  hasEliminationComp = FALSE,
  isFractionExcreted = FALSE,
  isSaturating = FALSE,
  infusionAllowed = FALSE,
  isDuration = FALSE,
  isStdevFrozen = FALSE,
  data = NULL,
  columnMap = TRUE,
  modelName = "",
  workingDir = "",
  ...
)

Arguments

isPopulation

Is this a population model TRUE or individual model FALSE?

parameterization

Type of parameterization. Options are "Clearance", "Micro", "Macro", or "Macro1".

absorption

Type of absorption. Options are "Intravenous", "FirstOrder", "Gamma", "InverseGaussian", "Weibull" .

numCompartments

Value of either 1, 2, or 3.

isClosedForm

Set to TRUE to convert model from a differential equation to close form.

isTlag

Set to TRUE to add a lag time parameter to the model.

hasEliminationComp

Set to TRUE to add an elimination compartment to the model.

isFractionExcreted

Set to TRUE if elimination compartment (hasEliminationComp = TRUE) contains a fraction excreted parameter.

isSaturating

Set to TRUE to use Michaelis-Menten kinetics for elimination. Only applicable to models with paramteterization = "Clearance"

infusionAllowed

Set to TRUE if infusions allowed.

isDuration

Set to TRUE if infusions use duration instead of rate (must also set infusionAllowed = TRUE).

isStdevFrozen

Set to TRUE to freeze value of standard deviation of residual error variable.

data

Input dataset

columnMap

If TRUE (default) column mapping arguments are required. Set to FALSE to manually map columns after defining model using colMapping.

modelName

Model name for subdirectory created for model output in current working directory.

workingDir

Working directory to run the model. Current working directory will be used if workingDir not specified.

...

Arguments passed on to pkmodel_MappingParameters

ID

Column mapping argument for input dataset column(s) that identify individual data profiles. Only applicable to population models isPopulation = TRUE.

Time

Column mapping argument that represents the input dataset column for the relative time used in a study and only applicable to time-based models.

A1

Column mapping argument that represents the input dataset column for the amount of drug administered. Only applicable to the following types of models:

  • Models with absorption = "Intravenous" and parameterization set to either "Clearance","Micro", or "Macro"

  • Models with absorption set to either "Gamma", "InverseGaussian", or "Weibull"

Aa

Column mapping argument that represents the input dataset column for the amount of drug administered and only applicable to models with absorption = "FirstOrder".

A

Column mapping argument that represents the input dataset column for the amount of drug administered and only applicable to models with absorption = "Intravenous" and parameterization = "Macro1".

A1_Rate

Column mapping argument that represents the input dataset column for the rate of drug administered. Only applicable to the following types of models:

  • Models with absorption = "Intravenous", infusionAllowed = TRUE and parameterization set to either "Clearance","Micro" or "Macro"

  • Models with absorption set to either "Gamma", "InverseGaussian", or "Weibull" and infusionAllowed = TRUE

A1_Duration

Column mapping argument that represents the input dataset column for the duration of drug administered. Only applicable to the following types of models:

  • Models with absorption = "Intravenous",infusionAllowed = TRUE with isDuration = TRUE and parameterization set to either "Clearance", "Micro" or "Macro"

  • Models with absorption set to either "Gamma", "InverseGaussian", or "Weibull" and infusionAllowed = TRUE with isDuration = TRUE

Aa_Rate

Column mapping argument that represents the input dataset column for the rate of drug administered and only applicable to models with absorption = "FirstOrder", infusionAllowed = TRUE.

Aa_Duration

Column mapping argument that represents the input dataset column for the duration of drug administered and only applicable to models with absorption = "FirstOrder", infusionAllowed = TRUE, and isDuration = TRUE.

A_Rate

Column mapping argument that represents the input dataset column for the rate of drug administered and only applicable to models with absorption = "Intravenous", infusionAllowed = TRUE, and parameterization = "Macro1".

A_Duration

Column mapping argument that represents the input dataset column for the duration of drug administered and only applicable to models with absorption = "Intravenous", infusionAllowed = TRUE, isDuration = TRUE, and parameterization = "Macro1".

A1Strip

Column mapping argument that represents the input dataset column for the stripping dose and only applicable to models with parameterization = "Macro".

CObs

Column mapping argument that represents the input dataset column for the observations of drug concentration in the central compartment and only applicable to models with parameterization being either set to either "Clearance" or "Micro".

C1Obs

Column mapping argument that represents the input dataset column for the observations of drug concentration in the central compartment and only applicable to models with parameterization being either set to either "Macro" or "Macro1".

A0Obs

Column mapping argument that represents the input dataset column for the observed amount of drug in the elimination compartment. (hasEliminationComp = TRUE).

Value

NlmePmlModel object

Column mapping

Note that quoted and unquoted column names are supported. Please see colMapping.

Examples

model <- pkmodel(
  parameterization = "Clearance",
  numCompartments = 2,
  data = pkData,
  ID = "Subject",
  Time = "Act_Time",
  A1 = "Amount",
  CObs = "Conc",
  workingDir = tempdir()
)

# View the model as well as its associated column mappings
print(model)


PK model mapping parameters

Description

PK model mapping parameters

Usage

pkmodel_MappingParameters(
  ID = NULL,
  Time = NULL,
  A1 = NULL,
  Aa = NULL,
  A = NULL,
  A1_Rate = NULL,
  A1_Duration = NULL,
  Aa_Rate = NULL,
  Aa_Duration = NULL,
  A_Rate = NULL,
  A_Duration = NULL,
  A1Strip = NULL,
  CObs = NULL,
  C1Obs = NULL,
  A0Obs = NULL
)

Arguments

ID

Column mapping argument for input dataset column(s) that identify individual data profiles. Only applicable to population models isPopulation = TRUE.

Time

Column mapping argument that represents the input dataset column for the relative time used in a study and only applicable to time-based models.

A1

Column mapping argument that represents the input dataset column for the amount of drug administered. Only applicable to the following types of models:

  • Models with absorption = "Intravenous" and parameterization set to either "Clearance","Micro", or "Macro"

  • Models with absorption set to either "Gamma", "InverseGaussian", or "Weibull"

Aa

Column mapping argument that represents the input dataset column for the amount of drug administered and only applicable to models with absorption = "FirstOrder".

A

Column mapping argument that represents the input dataset column for the amount of drug administered and only applicable to models with absorption = "Intravenous" and parameterization = "Macro1".

A1_Rate

Column mapping argument that represents the input dataset column for the rate of drug administered. Only applicable to the following types of models:

  • Models with absorption = "Intravenous", infusionAllowed = TRUE and parameterization set to either "Clearance","Micro" or "Macro"

  • Models with absorption set to either "Gamma", "InverseGaussian", or "Weibull" and infusionAllowed = TRUE

A1_Duration

Column mapping argument that represents the input dataset column for the duration of drug administered. Only applicable to the following types of models:

  • Models with absorption = "Intravenous",infusionAllowed = TRUE with isDuration = TRUE and parameterization set to either "Clearance", "Micro" or "Macro"

  • Models with absorption set to either "Gamma", "InverseGaussian", or "Weibull" and infusionAllowed = TRUE with isDuration = TRUE

Aa_Rate

Column mapping argument that represents the input dataset column for the rate of drug administered and only applicable to models with absorption = "FirstOrder", infusionAllowed = TRUE.

Aa_Duration

Column mapping argument that represents the input dataset column for the duration of drug administered and only applicable to models with absorption = "FirstOrder", infusionAllowed = TRUE, and isDuration = TRUE.

A_Rate

Column mapping argument that represents the input dataset column for the rate of drug administered and only applicable to models with absorption = "Intravenous", infusionAllowed = TRUE, and parameterization = "Macro1".

A_Duration

Column mapping argument that represents the input dataset column for the duration of drug administered and only applicable to models with absorption = "Intravenous", infusionAllowed = TRUE, isDuration = TRUE, and parameterization = "Macro1".

A1Strip

Column mapping argument that represents the input dataset column for the stripping dose and only applicable to models with parameterization = "Macro".

CObs

Column mapping argument that represents the input dataset column for the observations of drug concentration in the central compartment and only applicable to models with parameterization being either set to either "Clearance" or "Micro".

C1Obs

Column mapping argument that represents the input dataset column for the observations of drug concentration in the central compartment and only applicable to models with parameterization being either set to either "Macro" or "Macro1".

A0Obs

Column mapping argument that represents the input dataset column for the observed amount of drug in the elimination compartment. (hasEliminationComp = TRUE).

Column mapping

Note that quoted and unquoted column names are supported. Please see colMapping.


Pharmacokinetic/Pharmacodynamic dataset containing 200 subjects with single bolus dose

Description

Pharmacokinetic/Pharmacodynamic dataset containing 200 subjects with single bolus dose.

Usage

pkpdData

Format

A data frame with 2600 rows and 5 variables:

ID

Subject ID

Time

Nominal Time

Dose

Amount of dose

CObs

Observations of drug concentration in blood

EObs

Observations of drug effect

Source

The data is simulated using a PKPD model with PK described by a one-compartment model with IV bolus and PD described by an indirect response model with the loss inhibited.


Print generic for class NlmeEngineExtraParams

Description

Print generic for class NlmeEngineExtraParams

Usage

## S3 method for class 'NlmeEngineExtraParams'
print(x, ...)

Arguments

x

NlmeEngineExtraParams class instance

...

Arguments passed to methods.

Value

NULL

Examples

print(NlmeEngineExtraParams())

Print an NlmeParallelHost Object

Description

Prints a summary of the configuration of an NlmeParallelHost object.

Usage

## S3 method for class 'NlmeParallelHost'
print(x, ...)

Arguments

x

An NlmeParallelHost object to print.

...

Additional arguments passed to the print function.

Value

NULL. This function is called for its side effect of printing to the console.

Examples

host <- NlmeParallelHost(
  sharedDirectory = "~/shared/",
  installationDirectory = "~/nlme/",
  hostName = "my_host",
  machineName = "192.168.1.100",
  hostType = "RHEL",
  numCores = 8,
  isLocal = FALSE,
  rLocation = "/usr/bin/R",
  scriptPath = "/path/to/script.R",
  userAuthentication =
    NlmeUserAuthentication(userName = "myuser", userPassword = "mypassword"),
  parallelMethod = NlmeParallelMethod("SGE_MPI")
)

print(host)


Print generic for class NlmePmlModel

Description

Prints model information, including PML and column mappings.

Usage

## S3 method for class 'NlmePmlModel'
print(x, ...)

Arguments

x

NlmePmlModel class instance

...

Arguments passed to methods.

Value

NULL

Examples

model <- pkmodel(columnMap = FALSE,
                 data = pkData,
                 workingDir = tempdir())
print(model)


Print generic for class Simple.NlmeJob

Description

Reads progress file and prints out its contents. Applicable to remote jobs or jobs running in backgroud.

Usage

## S3 method for class 'SimpleNlmeJob'
print(x, ...)

Arguments

x

Handle to an NLME job

...

Arguments passed to methods.

Value

NULL

Examples


model <- pkmodel(
  parameterization = "Clearance",
  numCompartments = 2,
  data = pkData,
  ID = "Subject",
  Time = "Act_Time",
  A1 = "Amount",
  CObs = "Conc",
  workingDir = tempdir()
  )
 host <- hostParams(sharedDirectory = tempdir(),
                    parallelMethod = "None",
                    hostName = "local",
                    numCores = 1)
if (.Platform$OS.type == "unix") {
# background is not supported on Windows
  job <- fitmodel(model,
                  numIterations = 3,
                  hostPlatform = host,
                  runrunInBackground = TRUE)
  print(job)
}


Executes an NLME profile perturbation

Description

Executes an NLME profile perturbation

Usage

profilePertubate(
  hostPlatform,
  params = NULL,
  profiles,
  model = NULL,
  sortColumns = SortColumns(""),
  scenarios = list(),
  runInBackground = FALSE
)

Arguments

hostPlatform

How to execute the run(NlmeParallelHost)

params

Engine parameters(NlmeEngineExtraParams)

profiles

Profiles to perturbate(ProfileParameters)

model

PK/PD model

sortColumns

Optional list of columns to sort and fit(SortColumns)

scenarios

Optional list of scenarios to fit(NlmeScenario)

runInBackground

Set to TRUE to run in background and return prompt(Bool)

Value

List of results from NLME execution.

Examples


  model <- pkmodel(
    parameterization = "Clearance",
    numCompartments = 2,
    data = pkData,
    ID = "Subject",
    Time = "Act_Time",
    A1 = "Amount",
    CObs = "Conc",
    workingDir = tempdir()
  )

  params <- NlmeEngineExtraParams(
    method = 3,
    numIterations = 1
  )

  host <- hostParams(
    sharedDirectory = tempdir(),
    parallelMethod = "MULTICORE",
    hostName = "local",
    numCores = 4
  )

  profile1 <- ProfileVar(
    "tvV",
    9.548,
    "-2,2"
  )

  profile2 <- ProfileVar(
    "tvCl",
    0.919,
    "-0.5,1.5"
  )

  profiles <- ProfileParameters(
    "USE_DELTA",
    c(profile1, profile2)
  )

  job <- profilePertubate(
    hostPlatform = host,
    params = params,
    profiles = profiles,
    model = model
  )


Returns random block statement

Description

Returns random block statement

Usage

randomBlockStatement(.Object)

Arguments

.Object

PK/PD model


Sets or updates the covariance matrix of random effects

Description

Use to set or update the covariance matrix of random effects in a model object.

Usage

randomEffect(
  .Object,
  effect,
  value = NULL,
  isDiagonal = TRUE,
  isFrozen = FALSE,
  ...
)

Arguments

.Object

Model object

effect

One or more names of available random effects.

value

Initial values for the diagonal elements of the covariance matrix of random effects (if isDiagonal = TRUE, or initial values for the lower triangular elements (including diagonal elements) of the covariance matrix (if isDiagonal = FALSE) in a row-wise order.

isDiagonal

Set to TRUE to if the covariance matrix of the specified random effects is a diagonal matrix. or FALSE if not.

isFrozen

Set to TRUE to freeze the covariance matrix of random effects.

...

Additional arguments

Value

Modified NlmePmlModel object

Examples

model <- pkmodel(
  numCompartments = 2,
  data = pkData,
  ID = "Subject",
  Time = "Act_Time",
  A1 = "Amount",
  CObs = "Conc",
  modelName = "TwCpt_IVBolus_FOCE_ELS",
  workingDir = tempdir()
  )

model <-
  randomEffect(model,
               effect = c("nV", "nCl", "nCl2"), value = rep(0.1, 3))

Remove covariate from structural parameters in a model object.

Description

Remove one or more covariates from structural parameters in a model object.

Usage

removeCovariate(.Object, covariate = NULL, paramName = NULL)

Arguments

.Object

Model object

covariate

Covariates to remove from model. If NULL all covariates will be removed from model.

paramName

Structural parameters for which to remove covariate effect(s) from. If NULL covariate effect will be removed from all structural parameters.

Value

Modified NlmePmlModel object

Examples

model <- pkmodel(
  numCompartments = 2,
  data = pkData,
  ID = "Subject",
  Time = "Act_Time",
  A1 = "Amount",
  CObs = "Conc",
  workingDir = tempdir()
)

# Add Gender covariate of type categorical
model <- addCovariate(model,
  covariate = "Gender",
  type = "Categorical",
  effect = c("V2", "Cl2"),
  levels = c(0, 1),
  labels = c("Female", "Male")
)

# Add BodyWeight covariate of type continuous
model <- addCovariate(model,
  covariate = "BodyWeight",
  type = "Continuous",
  direction = "Backward",
  center = "Mean",
  effect = c("V", "Cl")
)

# Remove all covariates from model
model <- removeCovariate(model)


Remove NLME License

Description

This function attempts to remove an NLME license using the specified installation directory and licensing tool.

Usage

remove_NLMELicense(InstallDir = Sys.getenv("INSTALLDIR"))

Arguments

InstallDir

A character string specifying the directory where the NLME Engine is installed e.g., INSTALLDIR environment variable. The cadlicensingtool executable is expected to be located within this directory, or within a subdirectory specified by the PML_BIN_DIR environment variable.

Details

The function checks for the presence of the necessary 'appsettings.json' file in the specified directory or the CAD config file specified by the 'CAD_CONFIG_FILE' environment variable, runs the licensing tool to log out the user, and attempts to remove the NLME license.

Value

A logical value indicating whether the license information was successfully removed.

Examples


INSTALLDIR <- Sys.getenv("INSTALLDIR")
if (INSTALLDIR == "") INSTALLDIR <- "C:/Program Files/Certara/NLME_Engine"
if (FALSE) { # to prevent unintended logout
  result <- remove_NLMELicense(INSTALLDIR)
}


Sets residual effect attributes

Description

Sets residual effect attributes

Usage

residualEffect(.Object, effectName) <- value

Arguments

.Object

PK/PD model object

effectName

Effect to lookup/set attributes for

value

A value to be set


Return residual effect terms available in model

Description

Use to return character vector of residual effect names in model object

Usage

residualEffectNames(model)

Arguments

model

Object of class NlmePmlModel

Value

Character vector of residual effect names

Examples


model <- pkemaxmodel(columnMap = FALSE)
residualEffectNames(model)


Assign residual error model to model object

Description

Use to change or update residual error model for model object

Usage

residualError(
  .Object,
  predName = "C",
  errorType = NULL,
  SD = NULL,
  isFrozen = FALSE,
  isBQL = FALSE,
  staticLLOQ = NULL,
  EObsBQL = NULL,
  CObsBQL = NULL,
  C1ObsBQL = NULL,
  A0ObsBQL = NULL,
  exponent = NULL
)

Arguments

.Object

Model object

predName

Name of the predicted variable as returned in residualEffectNames.

errorType

Options are "Additive", "LogAdditive", "Multiplicative", "AdditiveMultiplicative", "MixRatio", "Power".

SD

Value for the standard deviation of the residual error variable.

isFrozen

Set to TRUE to freeze the standard deviation to the value specified for SD.

isBQL

Set to TRUE if BQL values present in the observation data.

staticLLOQ

Optional LLOQ value if isBQL = TRUE

EObsBQL

Column mapping argument that represents the input dataset column that contains the BQL flag for observation values corresponding to EObs. Only applicable to isBQL = TRUE.

CObsBQL

Column mapping argument that represents the input dataset column that contains the BQL flag for observation values corresponding to CObs. Only applicable to isBQL = TRUE.

C1ObsBQL

Column mapping argument that represents the input dataset column that contains the BQL flag for observation values corresponding to C1Obs. Only applicable to isBQL = TRUE.

A0ObsBQL

Column mapping argument that represents the input dataset column that contains the BQL flag for observation values corresponding to AObs. Only applicable to isBQL = TRUE.

exponent

Value of exponent. Only applicable to errorType = "Power".

Value

Modified NlmePmlModel object

Examples

model <- pkindirectmodel(indirectType = "LimitedInhibition", isBuildup = FALSE,
 data = pkpdData, ID = "ID", Time = "Time", A1 = "Dose", CObs = "CObs", EObs = "EObs")

residualEffectNames(model)

# Change error type to "Multiplicative" and value of SD to 0.1 for "E"
model <- residualError(model, predName = "E", errorType = "Multiplicative", SD = 0.1)

# Change error type to "Power", value of SD to 0.15, and set exponent = 2 for "C"
model <- residualError(model, predName = "C", errorType = "Power", SD = 0.15, exponent = 2)


Fit the NLME metamodel

Description

Use for simple model execution given information contained in mmdl file.

Usage

run_metamodel(mmdlfile, directoryToRun, nlme_hostPath, host)

Arguments

mmdlfile

The metamodel file path; relative paths are acceptable.

directoryToRun

The directory where the final results should be stored If missing, the mmdlfile base directory is used.

nlme_hostPath

json file with host definition for model execution. Generated by Pirana application. Consider using host argument when running from R.

host

NlmeParallelHost() class instance.

Details

See Metamodel documentation.

If both nlme_hostPath and host specified, the former is used. If nlme_hostPath is missing, host is used instead. If both are missing, MPI local host with 4 threads is used for simple estimation mode, multicore host is used for the others.

Multiple ESTARGS/SIMARGS are supported, they are applied for the model sequentially, the results of previous estimation are applied to the model before the next one. ESTARGS queue is executed first, SIMARGS queue is executed the second.

Value

the results of fitmodel() run are returned if singular ESTARGS block is provided; otherwise a list of fitmodel() and simmodel() results are returned.

See Also

NlmeParallelHost, fitmodel

Examples


mmdlfile <- system.file("extdata/mmdlNoTime/test.mmdl",
                       package = "Certara.RsNLME",
                       mustWork = TRUE)
directoryToRun <- file.path(tempdir(TRUE), "MmdlNoTimeTest")
# using default host
mmdlResults <- run_metamodel(mmdlfile = mmdlfile,
                             directoryToRun = directoryToRun)



Save model object to .rda file

Description

Saves the model, engine, and host objects to a single model.rda file in model's working directory. If no working directory exists it will be created by default.

Usage

saveModel(model, engine = NULL, host = NULL)

Arguments

model

NlmePmlModel object

engine

Optional engine parameters to save with model

host

Optional host to save with model

Value

NULL

Examples


model <- emaxmodel(
  checkBaseline = TRUE,
  checkFractional = TRUE,
  checkInhibitory = TRUE,
  data = pkpdData,
  ID = "ID",
  C = "CObs",
  EObs = "EObs",
  workingDir = tempdir()
)

saveModel(model)



workhorse for change_ThetasMmdlin RsNLME.ModelBuilder

Description

workhorse for change_ThetasMmdlin RsNLME.ModelBuilder

Usage

saveUpdatedMetamodel(
  mmdl_withComments,
  mmdl_model,
  resmodel,
  metamodelFile,
  updateModel = TRUE,
  updatedBasedOn = "",
  updatedEstArgsBlock = NULL,
  updatedTablesBlock = NULL
)

Arguments

mmdl_withComments

the metamodel text to be substituted

mmdl_model

the old model from mmdl_withComments

resmodel

the model to be pasted

metamodelFile

the name of initial file with metamodel to be overwritten

Value

text of new metamodel


Get secondary parameter names

Description

Returns character vector of secondary parameter names for model object.

Usage

secondaryParameterNames(model)

Arguments

model

Object of class NlmePmlModel

Value

Character vector of secondary parameter names defined in model

Examples

model <- pkemaxmodel(columnMap = FALSE)
secondaryparms <- secondaryParameterNames(model)


Executes an NLME shotgun covariate search

Description

Executes an NLME shotgun covariate search

Usage

shotgunSearch(
  model,
  hostPlatform = NULL,
  params,
  covariateModel,
  runInBackground = FALSE,
  ...
)

Arguments

model

PK/PD model class object.

hostPlatform

Host definition for model execution. See hostParams. If missing, multicore local host with 4 threads is used.

params

Engine parameters. See engineParams. If missing, default parameters generated by engineParams(model) are used.

covariateModel

Covariate Effects Model providing the relationship between covariates and structural parameters to test (covariateModel(model)).

runInBackground

Set to TRUE to run in background and return prompt.

...

Additional arguments for hostParams or arguments available inside engineParams functions. If engineParams arguments are supplied through both params argument and additional argument (i.e., ellipsis), then the arguments in params will be ignored and only the additional arguments will be used with warning. If hostParams arguments are supplied through both the hostPlatform argument and the ellipses, values supplied to hostPlatform will be overridden by additional arguments supplied via the ellipses e.g., ....

Value

if runInBackground = FALSE, a data frame is returned with shotgun (all combinations given the covariate model) search results, i.e. "Overall" comma separated file. Otherwise the ShotgunNlmeJob class object is returned.

See Also

hostParams, engineParams

Examples


# Define the model
model <- pkmodel(numCompartments = 2,
                 data = pkData,
                 ID = "Subject",
                 Time = "Act_Time",
                 A1 = "Amount",
                 CObs = "Conc",
                 workingDir = tempdir())

# Add Gender covariate of type categorical
model <- addCovariate(model,
                      covariate = "Gender",
                      type = "Categorical",
                      effect = c("V2", "Cl2"),
                      levels = c(0, 1),
                      labels = c("Female", "Male"))

# Add Bodyweight covariate of type continuous
model <- addCovariate(model,
             covariate = "BodyWeight",
             type = "Continuous",
             direction = "Backward",
             center = "Mean",
             effect = c("V", "Cl"))

# Define the host
host <- hostParams(parallelMethod = "MULTICORE",
                   hostName = "local",
                   numCores = 8,
                   sharedDirectory = tempdir())

# Define the engine parameters
params <- engineParams(model, fastOptimization = TRUE, numIterations = 7)

# Define covariate model
cp <- covariateModel(model)

# Perform shotgun search
OverallDF <-  shotgunSearch(model = model,
                            hostPlatform = host,
                            params = params,
                            covariateModel = cp,
                            runInBackground = FALSE)



Executes an NLME simulation

Description

Executes an NLME simulation

Usage

simmodel(
  model,
  simParams,
  params,
  hostPlatform = NULL,
  runInBackground = FALSE,
  ...
)

Arguments

model

PK/PD model class object.

simParams

Simulation parameters. See NlmeSimulationParams. If missing, default parameters generated by NlmeSimulationParams() are used.

params

Engine parameters. See engineParams. The common parameters include: sort, ODE, rtolODE, atolODE, maxStepsODE. If missing, default parameters generated by engineParams(model) are used.

hostPlatform

Host definition for model execution. See hostParams. If missing, simple local host is used.

runInBackground

Set to TRUE to run in background and return prompt.

...

Additional class initializer arguments for NlmeSimulationParams, or arguments available inside hostParams or engineParams functions. If engineParams arguments are supplied through both params argument and additional argument (i.e., ellipsis), then the arguments in params will be ignored and only the additional arguments will be used with warning. If hostParams arguments are supplied through both hostPlatform argument and additional argument, then its slots will be overridden by additional arguments. In addition, if NlmeSimulationParams arguments are supplied through both simParams argument and additional argument, then its slots will be overridden by additional arguments.

Value

returns job properties if runInBackground is TRUE; if runInBackground is FALSE and the function is called in interactive mode, the resulted simulated tables wil be loaded and presented as a list; if runInBackground is FALSE and the function is called in non-interactive mode, the list returned will have just the full paths of the tables generated.

Examples


SimTableObs <- tableParams(
  name = "SimTableObs.csv",
  timesList = "0,1,2,4,4.9,55.1,56,57,59,60",
  variablesList = "C, CObs",
  timeAfterDose = FALSE,
  forSimulation = TRUE
)

simParams <- NlmeSimulationParams(
  numReplicates = 2,
  simulationTables = SimTableObs
)
# Define the model
model <- pkmodel(
  numComp = 2,
  absorption = "Extravascular",
  ID = "Subject",
  Time = "Act_Time",
  CObs = "Conc",
  Aa = "Amount",
  data = pkData,
  modelName = "PkModel",
  workingDir = tempdir()
)

host <- hostParams(
  sharedDirectory = tempdir(),
  parallelMethod = "NONE",
  hostName = "local",
  numCores = 1
 )

results <- simmodel(model, simParams, hostPlatform = host)
# with seed given additionally:
results <- simmodel(model, simParams, hostPlatform = host, seed = 3527)


Executes an NLME simple estimation with sort keys and given scenarios

Description

Executes an NLME simple estimation with sort keys and given scenarios

Usage

sortfit(
  model,
  hostPlatform = NULL,
  params,
  sortColumns,
  scenarios = list(),
  simpleTables,
  runInBackground = FALSE,
  filesToReturn = "*",
  ...
)

Arguments

model

PK/PD model class object.

hostPlatform

Host definition for model execution. See hostParams. If missing, PhoenixMPIDir64 is given and MPI is installed, MPI local host with 4 threads is used. If MPI is not found, local host without parallelization is used.

params

Engine parameters. See engineParams. If missing, default parameters generated by engineParams(model) are used.

sortColumns

List of sort columns. See SortColumns. If missing, empty sort columns argument is used and NLME dataset is used as is.

scenarios

List of scenarios with different sets of covariates. See NlmeScenario If missing, all covariates effects are considered as enabled.

simpleTables

Optional list of simple tables. See tableParams. By default a table named 'posthoc.csv' is returned with structural parameters values for all source data rows.

runInBackground

Set to TRUE to run in background and return prompt.

filesToReturn

Used to specify which files to be outputted to the model directory and loaded as returned value. By default, all the applicable files listed in the Value section will be outputted to the model directory and loaded as returned value. Only those files listed in the Value section can be specified. Simple regex patterns are supported for the specification.

...

Additional arguments for hostParams or arguments available inside engineParams functions. If engineParams arguments are supplied through both params argument and additional argument (i.e., ellipsis), then the arguments in params will be ignored and only the additional arguments will be used with warning. If hostParams arguments are supplied through both the hostPlatform argument and the ellipses, values supplied to hostPlatform will be overridden by additional arguments supplied via the ellipses e.g., ....

Details

All the results in tabular format have scenario column and sorts columns appended. The resulted logs (nlme7engine.log, err1.txt, dmp.txt, out.txt) are appended with a row delimiter where the name of the Scenario and sort values are specified.

Value

if runInBackground is FALSE, a list with main resulted dataframes is returned:

nlme7engine.log textual output is returned and loaded with the main information related to fitting. dmp.txt structure with the results of fitting (including LL by subject information) is returned and loaded. These 2 files are returned and loaded irrespective of filesToReturn argument value.

For individual models, additional dataframe with partial derivatives is returned:

For population models and the method specified is NOT Naive-Pooled, additional dataframes are returned:

If standard error computation was requested and it was successful, additional dataframes are returned:

If nonparametric method was requested (numIterNonParametric > 0) and the method specified in engineParams is NOT Naive-Pooled, additional dataframes are returned:

if runInBackground is TRUE, only current status of job is returned.

Non-loaded but returned files

The non-loaded but returned files in the model working directory are:

See Also

hostParams, engineParams, SortColumns, NlmeScenario, tableParams

Examples


input_data <- pkData

model <-
  pkmodel(numCompartments = 2,
          data = input_data,
          ID = "Subject",
          Time = "Act_Time",
          A1 = "Amount",
          CObs = "Conc",
          workingDir = tempdir())

model <-
  addCovariate(model,
               covariate = "BodyWeight",
               direction = "Backward",
               center = "Mean",
               effect = c("V", "Cl"))

# multicore
multicoreHost <-
   hostParams(parallelMethod = "Multicore",
              hostName = "multicore",
              numCores = 4,
              sharedDirectory = tempdir())

# specify scenarios
CovariateEffectNames <- listCovariateEffectNames(model)
combinations <-
  combn(c("", CovariateEffectNames),
        length(CovariateEffectNames),
        simplify = FALSE)

scenarioNames <-
  lapply(combinations,
         function(x) {paste(x, collapse = " ")})

scenarios <-
  lapply(scenarioNames,
         function(x, CovariateEffectNames) {
           CovariateCombinations <- unlist(strsplit(x, " ", fixed = TRUE))
           scenarioIndex <-
             paste(which(CovariateEffectNames %in% CovariateCombinations,
                         arr.ind = TRUE),
                         collapse = ", ")
           NlmeScenario(trimws(x), scenarioIndex)
         },
         CovariateEffectNames)

res <-
  sortfit(model,
          hostPlatform = multicoreHost,
          params = engineParams(model, numIterations = 5, fastOptimization = TRUE),
          sortColumns = SortColumns("Gender"),
          scenarios = scenarios)



Executes an NLME stepwise covariate search

Description

Executes an NLME stepwise covariate search

Usage

stepwiseSearch(
  model,
  hostPlatform = NULL,
  params,
  covariateModel,
  stepwiseParams,
  runInBackground = FALSE,
  ...
)

Arguments

model

PK/PD model class object.

hostPlatform

Host definition for model execution. See hostParams. If missing, multicore local host with 4 threads is used.

params

Engine parameters. See engineParams. If missing, default parameters generated by engineParams(model) are used.

covariateModel

Covariate Effects Model providing the relationship between covariates and structural parameters to test (covariateModel(model)).

stepwiseParams

Stepwise parameters defining decision tree. See StepwiseParams

runInBackground

Set to TRUE to run in background and return prompt.

...

Additional arguments for hostParams or arguments available inside engineParams functions. If engineParams arguments are supplied through both params argument and additional argument (i.e., ellipsis), then the arguments in params will be ignored and only the additional arguments will be used with warning. If hostParams arguments are supplied through both the hostPlatform argument and the ellipses, values supplied to hostPlatform will be overridden by additional arguments supplied via the ellipses e.g., ....

Value

if runInBackground = FALSE, a data frame is returned with stepwise search results, i.e. "Overall" comma separated file. Otherwise the StepwiseNlmeJob class object is returned.

See Also

hostParams, engineParams

Examples


# Define the model
model <- pkmodel(numCompartments = 1,
                 data = pkData,
                 ID = "Subject",
                 Time = "Act_Time",
                 A1 = "Amount",
                 CObs = "Conc",
                 workingDir = tempdir())

# Add Gender covariate of type categorical
model <- addCovariate(model,
                      covariate = "Gender",
                      type = "Categorical",
                      effect = c("V", "Cl"),
                      levels = c(0, 1),
                      labels = c("Female", "Male"))

# Add Bodyweight covariate of type continuous
model <- addCovariate(model,
             covariate = "BodyWeight",
             type = "Continuous",
             direction = "Backward",
             center = "Mean",
             effect = c("V", "Cl"))

# Define the host
defaultHost <- hostParams(parallelMethod = "MULTICORE",
                   hostName = "local",
                   numCores = 8,
                   sharedDirectory = tempdir())

# Define the engine parameters
params <- engineParams(model, numIterations = 6)

# Define covariate model
cp <- covariateModel(model)

# Define the stepwise parameters
sp <- StepwiseParams(0.01, 0.001, "-2LL")

# Perform stepwise search
OverallDF <-  stepwiseSearch(model = model,
                      hostPlatform = defaultHost,
                      params = params,
                      covariateModel = cp,
                      stepwiseParams = sp,
                      runInBackground = FALSE)



Set structural parameter in model object

Description

Use to specify the relationship of the structural parameter with corresponding fixed effect, random effect, and covariate.

Usage

structuralParameter(
  .Object,
  paramName,
  fixedEffName = NULL,
  randomEffName = NULL,
  style = "LogNormal",
  hasRandomEffect = NULL
)

Arguments

.Object

Model object

paramName

Name of the structural parameter

fixedEffName

Name of the corresponding fixed effect

randomEffName

Name of the corresponding random effect; only applicable to population models.

style

Use to specify the relationship of the structural parameter with its corresponding fixed effect, random effect, and covariate, if exists.

  • "LogNormal" (Default): The structural parameter is defined as Product * exp(Eta)

  • "LogNormal1": The structural parameter is defined as Sum * exp(Eta)

  • "LogNormal2": The structural parameter is defined as exp(Sum + Eta)

  • "LogitNormal": The structural parameter is defined as ilogit(Sum + Eta)

  • "Normal": The structural parameter is defined as Sum + Eta)

Product denotes the product of the corresponding fixed effect and covariate effect terms (if exists), Eta represents the corresponding random effect, and Sum denotes the sum of its corresponding fixed effect and covariate effect terms (if exists).

hasRandomEffect

Set to FALSE to remove the corresponding random effect from the model. Only applicable to population models. If NULL the system will automatically set hasRandomEffect = TRUE for population models, and hasRandomEffect = FALSE for individual models.

Value

Modified NlmePmlModel object

Examples


model <- pkindirectmodel(
  indirectType = "LimitedInhibition",
  isBuildup = FALSE,
  data = pkpdData,
  ID = "ID",
  Time = "Time",
  A1 = "Dose",
  CObs = "CObs",
  EObs = "EObs"
)

# Change style of structural parameter "Imax" to "LogitNormal"
# and rename fixed effect to "tvlogitImax"
model <- structuralParameter(model,
  paramName = "Imax",
  style = "LogitNormal", fixedEffName = "tvlogitImax"
)

# Remove random effect for structural parameter "IC50"
model <- structuralParameter(model,
  paramName = "IC50",
  hasRandomEffect = FALSE
)


Get structural parameter names

Description

Returns character vector of structural parameter names for model object.

Usage

structuralParameterNames(model, omitEmpties = TRUE)

Arguments

model

Object of class NlmePmlModel

omitEmpties

Set to TRUE to omit empty names

Value

Character vector of structural parameter names defined in model

Examples

model <- pkemaxmodel(columnMap = FALSE)
stparms <- structuralParameterNames(model)


Wrapper around NlmeTableDef/NlmeSimTableDef-classes initializers.

Description

Wrapper around NlmeTableDef/NlmeSimTableDef-classes initializers.

Usage

tableParams(
  name = "",
  timesList = numeric(0),
  covrSet = "",
  whenDose = "",
  whenObs = "",
  variablesList = "",
  keepSource = FALSE,
  timeAfterDose = FALSE,
  IRES = FALSE,
  Weight = FALSE,
  IWRES = FALSE,
  mode = "all",
  forSimulation = FALSE
)

Arguments

name

Name of the generated simulation file.

timesList

Numeric; Time values for simulation. Applicable for time-based models only. Ignored when "keepSource=TRUE"

covrSet

Character; Vector of covariate names. Simulation point is added when the covariate value is set. See covariateNames

whenDose

Character; Vector of dosing compartment names. Simulation point is added when the dose value is set.

whenObs

Character; String of observed variables names. Simulation point is added when the observation value is set.

variablesList

Character; List of variables from the model for simulation.

keepSource

Logical; Set to TRUE to keep the number of rows appearing in the table the same as the number of rows in the input dataset.

timeAfterDose

Set to TRUE to output time after dose.

IRES

Logical; Set to TRUE to output individual residuals. Valid only if whenObs is specified.

Weight

Logical; Set to TRUE to output the weight of current observation. Valid only if whenObs is specified.

IWRES

Logical; Set to TRUE to output individual weighted residuals. Valid only if whenObs is specified.

mode

Character; The mode of output. Options are "all" (default), "unique", "first". Only applicable to non time-based models for the case where only covrSet is defined or the case where only covrSet and variablesList are defined.

Option "all" (default): it outputs all the rows invoked by specified covariates. Option "unique": if the values in a row are the same as the ones in the previous row for the current subject, then the row is omitted; otherwise, it is printed out. Option "first": it outputs only the first row for each subject.

forSimulation

logical. Defining whether the table is for simulation purposes or for postprocessing after fit. Default is FALSE.

Value

NlmeTableDef object if forSimulation is FALSE, NlmeSimTableDef object otherwise.

Examples

Table1 <- tableParams(
  name = "Table1.csv",
  timesList = seq(0, 24, 2),
  whenObs = c("CObs"),
  variablesList = "C",
  IRES = TRUE,
  IWRES = TRUE,
  Weight = TRUE)

SimTable1 <- tableParams(
  name = "SimTable1.csv",
  variablesList = "CL, V",
  keepSource = TRUE,
  forSimulation = TRUE)


Create a textual model object

Description

Use to create an empty model object and optionally supply location of .mdl file to initialize model with PML statements.

Usage

textualmodel(modelName = "", workingDir = "", data, mdl = NULL)

Arguments

modelName

Model name to create subdirectory for model output in current working directory.

workingDir

Working directory to run the model. Current working directory will be used if workingDir not specified.

data

Input dataset

mdl

File path specifying location of test.mdl file

Value

NlmePmlModel object

Examples


model <- textualmodel(data = pkData)



Perform visual predictive check for NLME models

Description

Perform visual predictive check for NLME models

Usage

vpcmodel(
  model,
  vpcParams,
  params,
  hostPlatform = NULL,
  runInBackground = FALSE,
  ...
)

Arguments

model

PK/PD model class object.

vpcParams

VPC argument setup. See NlmeVpcParams. If missing, default values generated by NlmeVpcParams() are used.

params

Engine argument setup. See engineParams. The following arguments are the subject of interest: sort, ODE, rtolODE, atolODE, maxStepsODE. If missing, default values generated by engineParams(model) are used.

hostPlatform

Host definition for model execution. See hostParams. If missing, simple local host is used.

runInBackground

Set to TRUE to run in background and return prompt.

...

Additional class initializer arguments for NlmeVpcParams or hostParams, or arguments available inside engineParams functions. If engineParams arguments are supplied through both params argument and additional argument (i.e., ellipsis), then the arguments in params will be ignored and only the additional arguments will be used with warning. If hostParams arguments are supplied through both hostPlatform argument and additional argument, then its values will be overridden by additional arguments. In addition, if NlmeVpcParams arguments are supplied through both vpcParams argument and additional argument, then its slots will be overridden by additional arguments.

Value

if runInBackground is TRUE, it returns job properties. Otherwise,

Examples


model <- pkmodel(
  numComp = 1,
  absorption = "Extravascular",
  ID = "Subject",
  Time = "Act_Time",
  CObs = "Conc",
  Aa = "Amount",
  data = pkData,
  modelName = "PkModel",
  workingDir = tempdir()
)

 host <- hostParams(
  sharedDirectory = tempdir(),
  parallelMethod = "NONE",
  hostName = "local",
  numCores = 1
 )

job <- fitmodel(model = model,
                hostPlatform = host)

finalModelVPC <- copyModel(model,
                           acceptAllEffects = TRUE,
                           modelName = "model_VPC",
                           workingDir = tempdir())

# View the model
print(finalModelVPC)

# Set up VPC arguments to have PRED outputted to simulation output dataset "predout.csv"
vpcSetup <- NlmeVpcParams(outputPRED = TRUE)

# Run VPC using the default host, default values for the relevant NLME engine arguments
finalVPCJob <- vpcmodel(model = finalModelVPC, vpcParams = vpcSetup, hostPlatform = host)
# the same as:
# finalVPCJob <- vpcmodel(model = finalModelVPC, outputPRED = TRUE)

# Observed dataset predcheck0.csv
dt_ObsData <- finalVPCJob$predcheck0

# Simulation output dataset predout.csv
dt_SimData <- finalVPCJob$predout

# Add PRED from REPLICATE = 0 of simulation output dataset to observed input dataset
dt_ObsData$PRED <- dt_SimData[REPLICATE == 0]$PRED

# tidyvpc package VPC example:
# library(tidyvpc)
# library(magrittr)
# Create a regular VPC plot with binning method set to be "jenks"
# binned_VPC <- observed(dt_ObsData, x = IVAR, yobs = DV) %>%
# simulated(dt_SimData, ysim = DV) %>%
# binning(bin = "jenks") %>%
# vpcstats()

# plot_binned_VPC <- plot(binned_VPC)

# Create a pcVPC plot with binning method set to be "jenks"
# binned_pcVPC <- observed(dt_ObsData, x = IVAR, yobs = DV) %>%
#   simulated(dt_SimData, ysim = DV) %>%
#   binning(bin = "jenks") %>%
#   predcorrect(pred = PRED) %>%
#   vpcstats()

# plot_binned_pcVPC <- plot(binned_pcVPC)



Writes out data/column mapping and engine parameter files for the engine

Description

Writes out data/column mapping and engine parameter files for the engine

Usage

writeDefaultFiles(model, dataset, simParams, Tables, sortColumns = NULL)

Arguments

model

Model object

dataset

Dataset to run simulation/fitting on

simParams

Simulation Parameters (simulation tables are written to coldef)

Tables

NlmeTableDef class object(s)

sortColumns

SortColumns class object used for proper id mapping during individual modeling

Value

NULL

mirror server hosted at Truenetwork, Russian Federation.