| Title: | Interface for 'pyDarwin' Machine Learning Pharmacometric Model Development |
|---|---|
| Description: | Utilities that support the usage of 'pyDarwin' (<https://certara.github.io/pyDarwin/>) for ease of setup and execution of a machine learning based pharmacometric model search with Certara's Non-Linear Mixed Effects (NLME) modeling engine. |
| Authors: | Michael Tomashevskiy [aut], James Craig [aut, cre], Certara USA, Inc [cph, fnd] |
| Maintainer: | James Craig <[email protected]> |
| License: | LGPL-3 |
| Version: | 1.2.0 |
| Built: | 2026-06-02 08:26:23 UTC |
| Source: | https://github.com/cran/Certara.RDarwin |
Add Covariate into PML models
add_Covariate( PMLParametersSets, Name, Type = "Continuous", StParmNames = NULL, State = "Present", Direction = "Forward", Center = "None", Categories = c(), PMLStructures = NULL )add_Covariate( PMLParametersSets, Name, Type = "Continuous", StParmNames = NULL, State = "Present", Direction = "Forward", Center = "None", Categories = c(), PMLStructures = NULL )
PMLParametersSets |
A list of PML parameters sets ( |
Name |
A character string representing the name of the covariate to be added. |
Type |
A character specifying the type of the covariate. Possible values are:
|
StParmNames |
Character or character vector specifying names of
structural parameters to which covariates should be added. Can be set to
|
State |
A character string representing the presence of the covariate on the structural parameters. Possible values are:
|
Direction |
A character string representing the direction of the
Covariate. Options are |
Center |
A character string ( |
Categories |
A numeric vector representing the categories (at least two)
of the covariate. Applicable only if |
PMLStructures |
Character or character vector specifying names of PML
structures to which the covariate will be added. For the naming covention
of PMLStructures, see Details section of |
If Covariate already exists, it will be substituted with a new
instance with given properties. New covariate will have default bound
omegas/thetas. The user can change thetas with modify_Theta() and omegas
with modify_Omega().
The current functionality does not support adding or modifying custom covariates that are defined within the PML code of custom model spaces.
An updated list of PML models (PMLModels class instance) matching
the specified options.
list_Covariates() modify_Theta() modify_Omega()
Functions used for Covariate specification:
Covariate(),
create_ModelPD(),
create_ModelPK(),
remove_Covariate()
PMLParametersSets <- create_ModelPK() PMLParametersSetsWT <- add_Covariate(PMLParametersSets, Name = "WT", Type = "Continuous", State = "Present", Direction = "Forward", Center = 70) PMLParametersSetsWTCL <- add_Covariate(PMLParametersSets = PMLParametersSetsWT, Name = "Race", Type = "Categorical", State = "Searched", Direction = "Backward", Categories = c(1,2,3), StParmNames = "Cl", PMLStructure = "PK1IVC")PMLParametersSets <- create_ModelPK() PMLParametersSetsWT <- add_Covariate(PMLParametersSets, Name = "WT", Type = "Continuous", State = "Present", Direction = "Forward", Center = 70) PMLParametersSetsWTCL <- add_Covariate(PMLParametersSets = PMLParametersSetsWT, Name = "Race", Type = "Categorical", State = "Searched", Direction = "Backward", Categories = c(1,2,3), StParmNames = "Cl", PMLStructure = "PK1IVC")
Adds a new model space, defined by custom PML code, to an existing collection
of model spaces (a PMLModels object).
add_CustomSpace(Spaces, CustomCode, SpaceName = character())add_CustomSpace(Spaces, CustomCode, SpaceName = character())
Spaces |
A |
CustomCode |
A character string containing the complete custom PML code
(e.g., the content of a |
SpaceName |
An optional character string specifying the name for this
custom model space. This name will be used as the key for this model within
the returned |
This function serves as a wrapper around create_CustomSpace(). It first
calls create_CustomSpace using the provided CustomCode and SpaceName
to parse the code and create a representation of the new custom space.
The name of this new space is either the provided SpaceName or one
automatically generated by create_CustomSpace if SpaceName was omitted
or empty (e.g., "l<number>" based on code length).
An updated PMLModels object (a named list) containing all the
original spaces plus the newly added custom space.
create_CustomSpace(), add_Spaces(), create_ModelPK(),
create_ModelPD()
# Start with some built-in models pk_models <- create_ModelPK(CompartmentsNumber = 1) # Define custom code custom_pml <- "test() { cfMicro(A1, Cl / V) dosepoint(A1) C = A1 / V error(CEps = 1) observe(CObs = C + CEps) stparm(V = tvV * exp(nV)) stparm(Cl = tvCl * exp(nCl)) fixef(tvV = c(, 1, )) fixef(tvCl = c(, 1, )) ranef(block(nV, nCl) = c(1, 0.001, 1)) } " # Add custom space with an explicit name all_models <- add_CustomSpace(pk_models, custom_pml, SpaceName = "1cptOmegaBlock") names(all_models) # Add another custom space with auto-generated name all_models_2 <- add_CustomSpace(all_models, "test() { cfMicro(A1, Cl / V) dosepoint(A1) C = A1 / V error(CEps = 1) observe(CObs = C + C ^ (0.5) * CEps) stparm(V = tvV * exp(nV)) stparm(Cl = tvCl * exp(nCl)) fixef(tvV = c(, 1, )) fixef(tvCl = c(, 1, )) ranef(block(nV, nCl) = c(1, 0.001, 1)) } ") names(all_models_2) # Will include original names + "l<number>"# Start with some built-in models pk_models <- create_ModelPK(CompartmentsNumber = 1) # Define custom code custom_pml <- "test() { cfMicro(A1, Cl / V) dosepoint(A1) C = A1 / V error(CEps = 1) observe(CObs = C + CEps) stparm(V = tvV * exp(nV)) stparm(Cl = tvCl * exp(nCl)) fixef(tvV = c(, 1, )) fixef(tvCl = c(, 1, )) ranef(block(nV, nCl) = c(1, 0.001, 1)) } " # Add custom space with an explicit name all_models <- add_CustomSpace(pk_models, custom_pml, SpaceName = "1cptOmegaBlock") names(all_models) # Add another custom space with auto-generated name all_models_2 <- add_CustomSpace(all_models, "test() { cfMicro(A1, Cl / V) dosepoint(A1) C = A1 / V error(CEps = 1) observe(CObs = C + C ^ (0.5) * CEps) stparm(V = tvV * exp(nV)) stparm(Cl = tvCl * exp(nCl)) fixef(tvV = c(, 1, )) fixef(tvCl = c(, 1, )) ranef(block(nV, nCl) = c(1, 0.001, 1)) } ") names(all_models_2) # Will include original names + "l<number>"
Add Dosepoint in PML models
add_Dosepoint( PMLParametersSets, DosepointName = "A1", State = "Present", tlag = c(), bioavail = c(), duration = c(), rate = c(), PMLStructures = NULL )add_Dosepoint( PMLParametersSets, DosepointName = "A1", State = "Present", tlag = c(), bioavail = c(), duration = c(), rate = c(), PMLStructures = NULL )
PMLParametersSets |
A list of PML parameters sets ( |
DosepointName |
A character string giving the name of the Dosepoint. |
State |
A character string giving the state of the Dosepoint, must be one of "None", "Present", "Searched". Default is "Present". |
tlag |
An optional parameter for the time lag. Can be an
|
bioavail |
An optional parameter for bioavailability. Can be an
|
duration |
An optional parameter for the duration of infusion. Can be an
|
rate |
An optional parameter for the rate of infusion. Can be an
|
PMLStructures |
Character or character vector specifying names of PML
structures in which the dosepoint statement will be modified. For the
naming convention of PMLStructures, see Details section of
|
An updated list of PML models (PMLModels class instance) matching
the specified options.
list_Dosepoints(), modify_Dosepoint()
Functions used for Dosepoint specification:
Dosepoint(),
create_ModelPK(),
modify_Dosepoint()
PMLParametersSets <- create_ModelPK(CompartmentsNumber = c(1, 2, 3), Absorption = c("First-Order")) # modify dosepoint PMLParametersSets <- modify_Dosepoint(PMLParametersSets, DosepointName = "Aa", tlag = StParm(StParmName = "Tlag", State = "Present"), bioavail = StParm(StParmName = "F", State = "Present")) # add dosepoint PMLParametersSets <- add_Dosepoint(PMLParametersSets, DosepointName = "A1", bioavail = Expression("1 - F"), duration = Expression("Tlag"))PMLParametersSets <- create_ModelPK(CompartmentsNumber = c(1, 2, 3), Absorption = c("First-Order")) # modify dosepoint PMLParametersSets <- modify_Dosepoint(PMLParametersSets, DosepointName = "Aa", tlag = StParm(StParmName = "Tlag", State = "Present"), bioavail = StParm(StParmName = "F", State = "Present")) # add dosepoint PMLParametersSets <- add_Dosepoint(PMLParametersSets, DosepointName = "A1", bioavail = Expression("1 - F"), duration = Expression("Tlag"))
Merges a list of new model spaces into an existing PMLModels object.
add_Spaces(Spaces, NewSpaces, NewSpacesNames = character())add_Spaces(Spaces, NewSpaces, NewSpacesNames = character())
Spaces |
A |
NewSpaces |
A list where each element is an internal representation of a
single model space (e.g., the list structure produced by |
NewSpacesNames |
An optional character vector providing explicit names for
the spaces listed in |
This function provides a general mechanism for combining collections of model spaces.
Naming and Collision Handling:
This behavior differs from add_CustomSpace(), which automatically renames
on collision. add_Spaces requires unique, non-colliding names for the merge.
An updated PMLModels object (a named list) containing all the
original spaces plus all spaces from NewSpaces. The class "PMLModels"
is preserved.
add_CustomSpace() for adding a single custom space with automatic renaming.
pk_model1 <- create_ModelPK(CompartmentsNumber = 1, Absorption = "Intravenous") pk_models2 <- create_ModelPK(CompartmentsNumber = c(2, 3), Absorption = "First-Order") # Combine two PMLModels objects (using names from pk_models2) combined1 <- add_Spaces(pk_model1, pk_models2) names(combined1) # Combine using explicit new names combined2 <- add_Spaces(pk_model1, pk_models2, NewSpacesNames = c("Model_A", "Model_B")) names(combined2) # Add a list containing a single custom space custom_pml <- "test(){ fixef(p=1) }" custom_space_list <- create_CustomSpace(custom_pml, "MyCustom") combined3 <- add_Spaces(pk_model1, custom_space_list) names(combined3)pk_model1 <- create_ModelPK(CompartmentsNumber = 1, Absorption = "Intravenous") pk_models2 <- create_ModelPK(CompartmentsNumber = c(2, 3), Absorption = "First-Order") # Combine two PMLModels objects (using names from pk_models2) combined1 <- add_Spaces(pk_model1, pk_models2) names(combined1) # Combine using explicit new names combined2 <- add_Spaces(pk_model1, pk_models2, NewSpacesNames = c("Model_A", "Model_B")) names(combined2) # Add a list containing a single custom space custom_pml <- "test(){ fixef(p=1) }" custom_space_list <- create_CustomSpace(custom_pml, "MyCustom") combined3 <- add_Spaces(pk_model1, custom_space_list) names(combined3)
Add Structural parameter into PML models Dosepoints
add_StParm( PMLParametersSets, StParmName, Type = "LogNormal", State = "Present", ThetaStParm = list(), OmegaStParm = list(), Covariates = list(), PMLStructures = NULL, DosepointArgName = character() )add_StParm( PMLParametersSets, StParmName, Type = "LogNormal", State = "Present", ThetaStParm = list(), OmegaStParm = list(), Covariates = list(), PMLStructures = NULL, DosepointArgName = character() )
PMLParametersSets |
A list of PML parameters sets ( |
StParmName |
Character specifying the name of the structural parameter to be added. |
Type |
Character specifying the type of the structural parameter. Options are
|
State |
character string that indicates the presence of the structural parameter. Options are:
|
ThetaStParm |
A Theta class instance inside the structural parameter. If
not given, the associated Theta will be automatically created with its name
set to "tv" + |
OmegaStParm |
An Omega class instance inside the structural parameter.
If not given, the associated Omega will be automatically created with its
name set to "n" + |
Covariates |
A list of covariates ( |
PMLStructures |
Character or character vector specifying names of PML
structures to which the structural parameter will be added. For the naming
convention of PMLStructures, see Details section of
|
DosepointArgName |
Character specifying the name of the argument in the
|
only special Dosepoint() related structural parameters could be
added to built-in models (i.e. created using either create_ModelPD() or
create_modelPK(). Due to ambiguity of situation when a structural parameter
is added with State == 'None', a warning is given for such cases.
A structural parameter could be added to the custom model if it not presented in the model yet (as a custom or built-in structural parameter).
An updated list of PML models (PMLModels class instance) matching
the specified options.
Functions used for StParm specification:
StParm(),
create_ModelPD(),
create_ModelPK(),
modify_StParm(),
modify_StParmCustom(),
remove_StParm()
PMLParametersSets <- get_PMLParametersSets(CompartmentsNumber = c(1, 2, 3)) # add Rate structural parameter for all PMLModels PMLParametersSetsVModDuration <- add_StParm(PMLParametersSets, StParmName = "Duration", ThetaStParm = Theta("tvD", InitialEstimates = 2), OmegaStParm = Omega(Name = "nD", State = "Searched"), DosepointArgName = "duration")PMLParametersSets <- get_PMLParametersSets(CompartmentsNumber = c(1, 2, 3)) # add Rate structural parameter for all PMLModels PMLParametersSetsVModDuration <- add_StParm(PMLParametersSets, StParmName = "Duration", ThetaStParm = Theta("tvD", InitialEstimates = 2), OmegaStParm = Omega(Name = "nD", State = "Searched"), DosepointArgName = "duration")
Create a new Covariate object and validate it
Covariate( Name = character(), Type = "Continuous", StParmName = character(), State = "Present", Direction = "Forward", Center = "None", Categories = c(), Thetas = c(), Omegas = c(), PMLStructure = character() )Covariate( Name = character(), Type = "Continuous", StParmName = character(), State = "Present", Direction = "Forward", Center = "None", Categories = c(), Thetas = c(), Omegas = c(), PMLStructure = character() )
Name |
Character specifying the name of the covariate. |
Type |
A character specifying the type of the covariate. Possible values are:
|
StParmName |
A character specifying the corresponding structural parameter name. |
State |
A character string representing the presence of the covariate on the structural parameters. Possible values are:
|
Direction |
A character string representing the direction of the
Covariate. Options are |
Center |
A character string ( |
Categories |
A numeric vector representing the categories (at least two)
of the covariate. Applicable only if |
Thetas |
A list of Theta objects representing Thetas covariate effects.
Only applicable if |
Omegas |
A list of Omega objects representing the Omegas of
the inter-occasion random effects. Applicable only if |
PMLStructure |
PML structure current Covariate instance belongs to. |
A Covariate object
Functions used for Covariate specification:
add_Covariate(),
create_ModelPD(),
create_ModelPK(),
remove_Covariate()
WT_Covariate <- Covariate(Name = "WT", Type = "Continuous", StParmName = "V", State = "Present", Direction = "Forward", Center = 70, Thetas = Theta("dVdWT", 1)) Race_Covariate <- Covariate( Name = "Race", Type = "Categorical", StParmName = "V2", State = "Searched", Direction = "Backward", Center = "None", Categories = c(1,2,3))WT_Covariate <- Covariate(Name = "WT", Type = "Continuous", StParmName = "V", State = "Present", Direction = "Forward", Center = 70, Thetas = Theta("dVdWT", 1)) Race_Covariate <- Covariate( Name = "Race", Type = "Categorical", StParmName = "V2", State = "Searched", Direction = "Backward", Center = "None", Categories = c(1,2,3))
Parses a character string containing custom PML code to create a structured
representation within the PMLModels framework. This allows integrating
user-defined models with the package's modification and generation tools.
create_CustomSpace(CustomCode = character(), SpaceName = character())create_CustomSpace(CustomCode = character(), SpaceName = character())
CustomCode |
A character string containing the complete custom PML code
(e.g., the content of a |
SpaceName |
An optional character string specifying the name for this
custom model space. This name will be used as the key for this model within
the returned |
This function acts as a parser for custom PML code. It attempts to identify
and extract various PML statements within the provided CustomCode string.
Recognized statements include:
Observations/Responses: observe(), error(), multi(), ordinal(), count(), event(), LL()
Structural Parameters: stparm()
Covariates: covariate() (parsed as backward), fcovariate() (parsed as forward), interpolate()
Dosing: dosepoint(), dosepoint2()
Parameter Definitions: ranef(), fixef()
Model Dynamics: deriv(), cfMicro(), cfMacro(), cfMacro1(), transit(), delayInfCpt()
Other Compartments: urinecpt()
The function cleans the code (removes comments, standardizes spacing) for
parsing most statements but uses the original code for stparm and fixef
parsing to preserve complex structures.
The extracted components are stored as specific S3 objects (e.g.,
ObservationCustom, StParmCustom, CovariateCustom, DosepointCustom)
within the list element corresponding to the SpaceName. This structured
representation allows the custom model to be potentially inspected or manipulated
by other package functions, although interacting with built-in models via
functions like modify_StParm is generally more robust than modifying custom
code components directly.
A list object of class PMLModels. This list contains a single
element, named according to the provided or generated SpaceName. The
value of this element is an internal list structure (created by the internal
CustomSpace function) holding the original code and parsed components.
# Example custom PML code (simplified) custom_pml <- "test() { cfMicro(A1, Cl / V) dosepoint(A1) C = A1 / V error(CEps = 1) observe(CObs = C + CEps) stparm(V = tvV * exp(nV)) stparm(Cl = tvCl * exp(nCl)) fixef(tvV = c(, 1, )) fixef(tvCl = c(, 1, )) ranef(diag(nV, nCl) = c(1, 1)) } " # Create a custom space with an explicit name custom_model_set <- create_CustomSpace(CustomCode = custom_pml, SpaceName = "My1CptOral") # Print the structure (will show parsed components within the list element) # print(custom_model_set) # List the name of the created space names(custom_model_set) # Output: "My1CptOral" # Create a custom space with an automatically generated name custom_model_set_auto_name <- create_CustomSpace(CustomCode = custom_pml) names(custom_model_set_auto_name)# Example custom PML code (simplified) custom_pml <- "test() { cfMicro(A1, Cl / V) dosepoint(A1) C = A1 / V error(CEps = 1) observe(CObs = C + CEps) stparm(V = tvV * exp(nV)) stparm(Cl = tvCl * exp(nCl)) fixef(tvV = c(, 1, )) fixef(tvCl = c(, 1, )) ranef(diag(nV, nCl) = c(1, 1)) } " # Create a custom space with an explicit name custom_model_set <- create_CustomSpace(CustomCode = custom_pml, SpaceName = "My1CptOral") # Print the structure (will show parsed components within the list element) # print(custom_model_set) # List the name of the created space names(custom_model_set) # Output: "My1CptOral" # Create a custom space with an automatically generated name custom_model_set_auto_name <- create_CustomSpace(CustomCode = custom_pml) names(custom_model_set_auto_name)
This function provides the PML (Pharmacometric Modelling Language) Emax parameter sets based on the specified options. They are available as a list of specific S3 classes.
create_ModelEmax( Baseline = FALSE, Fractional = FALSE, Inhibitory = FALSE, Sigmoid = FALSE, ByVector = FALSE, ... )create_ModelEmax( Baseline = FALSE, Fractional = FALSE, Inhibitory = FALSE, Sigmoid = FALSE, ByVector = FALSE, ... )
Baseline |
Logical indicating whether the Emax model contains a baseline
response. If it is set to TRUE, the new parameter, E0, for baseline
response is added to the model. Default is |
Fractional |
Logical indicating whether the Emax model with baseline
response is fractional. Applicable only for the Emax models with baseline
response, otherwise a warning is given and current parameter is ignored.
Default is |
Inhibitory |
Logical indicating whether the model is inhibitory. If it
is set to TRUE, the structural parameters 'EC50' and 'Emax' change to
'IC50' (concentration producing 50% of maximal inhibition) and 'Imax'.
Default is |
Sigmoid |
Logical indicating whether the model is sigmoidal. If it is
set to TRUE, the Hill coefficient, 'Gam', is added to the model. Default is
|
ByVector |
Logical indicating whether each element in vectorized
argument should be treated as a separate PML structure (i.e. treated as
data.frame vectors), |
... |
Additional named arguments, including Structural parameters (StParm), Covariates, Dosepoints (for PK models), Thetas and Omegas. See 'Additional arguments' section. |
A list of PML models (PMLModels class instance) matching the
specified options.
# Get Emax model set with default options PDParametersSets <- create_ModelEmax() # Create Emax model set with all possible combinations # will give a warning since When 'Baseline == FALSE', # there could be no model with 'Fractional == TRUE' PDParametersSets <- create_ModelEmax(Baseline = TRUE, Fractional = c(FALSE, TRUE), Inhibitory = c(FALSE, TRUE), Sigmoid = c(FALSE, TRUE), ByVector = FALSE)# Get Emax model set with default options PDParametersSets <- create_ModelEmax() # Create Emax model set with all possible combinations # will give a warning since When 'Baseline == FALSE', # there could be no model with 'Fractional == TRUE' PDParametersSets <- create_ModelEmax(Baseline = TRUE, Fractional = c(FALSE, TRUE), Inhibitory = c(FALSE, TRUE), Sigmoid = c(FALSE, TRUE), ByVector = FALSE)
This function provides the PML (Pharmacometric Modelling Language) PD parameter sets based on the specified options. They are available as a list of specific S3 classes.
create_ModelPD( Type = "Emax", Baseline = FALSE, Fractional = FALSE, Inhibitory = FALSE, Sigmoid = FALSE, ByVector = FALSE, ... )create_ModelPD( Type = "Emax", Baseline = FALSE, Fractional = FALSE, Inhibitory = FALSE, Sigmoid = FALSE, ByVector = FALSE, ... )
Type |
Pharmacodynamic model type. Currently, only Emax is supported. |
Baseline |
Logical indicating whether the Emax model contains a baseline
response. If it is set to TRUE, the new parameter, E0, for baseline
response is added to the model. Default is |
Fractional |
Logical indicating whether the Emax model with baseline
response is fractional. Applicable only for the Emax models with baseline
response, otherwise a warning is given and current parameter is ignored.
Default is |
Inhibitory |
Logical indicating whether the model is inhibitory. If it
is set to TRUE, the structural parameters 'EC50' and 'Emax' change to
'IC50' (concentration producing 50% of maximal inhibition) and 'Imax'.
Default is |
Sigmoid |
Logical indicating whether the model is sigmoidal. If it is
set to TRUE, the Hill coefficient, 'Gam', is added to the model. Default is
|
ByVector |
Logical indicating whether each element in vectorized
argument should be treated as a separate PML structure (i.e. treated as
data.frame vectors), |
... |
Additional named arguments, including Structural parameters (StParm), Covariates, Dosepoints (for PK models), Thetas and Omegas. See 'Additional arguments' section. |
The names of PMLStructure are constructed by the following parts:
Baseline if presented (abbreviated as 'E0'),
Fractional if presented (abbreviated as '1+'),
Inhibitory (abbreviated as 'Imax' if the model is inhibitory and 'Emax' otherwise),
Sigmoid if presented (abbreviated as 'Gam').
A list of PML models (PMLModels class instance) matching the
specified options.
Additional arguments (ellipsis) will be applied
sequentially. They can be used to add or modify Structural parameters
(StParm), Covariates, Observations, Dosepoints (for PK models); by the way it is advised to
use specific functions for it (see 'See Also' section for the references).
Also it is possible to modify Omegas and Thetas, but it is impossible to add
them (they are parts of other structures). If PMLStructure argument is not
specified, class instances will be modified or added in all PML structures.
If PMLStructure argument is specified, class instances in the specified PML
structure will be modified/added. Note that only one PML structure could be
added to the class instance. If multiple structures should be modified,
suggest to use specific functions.
Functions used for StParm specification:
StParm(),
add_StParm(),
create_ModelPK(),
modify_StParm(),
modify_StParmCustom(),
remove_StParm()
Functions used for Observation specification:
Observation(),
ObservationCustom(),
Sigmas(),
create_ModelPK(),
modify_Observation(),
remove_Observation()
Functions used for Omega specification:
Omega(),
create_ModelPK(),
modify_Omega()
Functions used for Theta specification:
InitialEstimate(),
Theta(),
create_ModelPK(),
modify_Theta()
Functions used for Covariate specification:
Covariate(),
add_Covariate(),
create_ModelPK(),
remove_Covariate()
# Get PD model set with default options PDParametersSets <- create_ModelPD(Type = "Emax") # Create PD model set with all possible combinations # will give a warning since When 'Baseline == FALSE', # there could be no model with 'Fractional == TRUE' PDParametersSets <- create_ModelPD(Type = "Emax", Baseline = FALSE, Inhibitory = c(FALSE, TRUE), Sigmoid = c(FALSE, TRUE), ByVector = FALSE)# Get PD model set with default options PDParametersSets <- create_ModelPD(Type = "Emax") # Create PD model set with all possible combinations # will give a warning since When 'Baseline == FALSE', # there could be no model with 'Fractional == TRUE' PDParametersSets <- create_ModelPD(Type = "Emax", Baseline = FALSE, Inhibitory = c(FALSE, TRUE), Sigmoid = c(FALSE, TRUE), ByVector = FALSE)
This function provides the PML (Pharmacometric Modelling Language) PK parameter sets based on the specified options. They are available as a list of specific S3 classes.
create_ModelPK( CompartmentsNumber = 1, Absorption = "Intravenous", Parameterization = "Clearance", Saturation = FALSE, EliminationCpt = FALSE, FractionExcreted = FALSE, ByVector = FALSE, ClosedForm = TRUE, ... ) get_PMLParametersSets( CompartmentsNumber = 1, Absorption = "Intravenous", Parameterization = "Clearance", Saturation = FALSE, EliminationCpt = FALSE, FractionExcreted = FALSE, ByVector = FALSE, ClosedForm = TRUE, ... )create_ModelPK( CompartmentsNumber = 1, Absorption = "Intravenous", Parameterization = "Clearance", Saturation = FALSE, EliminationCpt = FALSE, FractionExcreted = FALSE, ByVector = FALSE, ClosedForm = TRUE, ... ) get_PMLParametersSets( CompartmentsNumber = 1, Absorption = "Intravenous", Parameterization = "Clearance", Saturation = FALSE, EliminationCpt = FALSE, FractionExcreted = FALSE, ByVector = FALSE, ClosedForm = TRUE, ... )
CompartmentsNumber |
The number of compartments in the model. Supported embedded models are 1-, 2-, 3-compartments. Default is 1. |
Absorption |
The absorption type of the model. Supported types are:
|
Parameterization |
The parameterization type. Possible options are
|
Saturation |
Logical indicating whether saturation should be considered.
Default is |
EliminationCpt |
Logical indicating whether elimination compartment
should be included. Default is |
FractionExcreted |
Logical indicating whether fraction excreted
structural parameter should be included in urinecpt statement: |
ByVector |
Logical indicating whether each element in vectorized
argument should be treated as a separate PML structure (i.e. treated as
data.frame vectors), |
ClosedForm |
Logical indicating whether closed forms (cfMicro) should be
used when possible. Note that closed forms are not available for the models
with elimination compartment, models with saturation or absorption types
other than |
... |
Additional named arguments, including Structural parameters (StParm), Covariates, Dosepoints (for PK models), Thetas and Omegas. See 'Additional arguments' section. |
The names of PMLStructure are constructed
by the following parts:
Model type ('PK'),
Compartments number
Abbreviated absorption type:
'IV' for Intravenous,
'FO' for First-Order,
'G' for Gamma,
'W' for Weibull,
'IG' for Inverse Gaussian,
Abbreviated parameterization ('C' for Clearance and 'M' for Micro),
Abbreviated saturation if presented ('S'),
Abbreviated elimination if presented ('E'),
Abbreviated fraction excreted if presented ('F').
A list of PML models (PMLModels class instance) matching the
specified options.
Additional arguments (ellipsis) will be applied
sequentially. They can be used to add or modify Structural parameters
(StParm), Covariates, Observations, Dosepoints (for PK models); by the way it is advised to
use specific functions for it (see 'See Also' section for the references).
Also it is possible to modify Omegas and Thetas, but it is impossible to add
them (they are parts of other structures). If PMLStructure argument is not
specified, class instances will be modified or added in all PML structures.
If PMLStructure argument is specified, class instances in the specified PML
structure will be modified/added. Note that only one PML structure could be
added to the class instance. If multiple structures should be modified,
suggest to use specific functions.
Functions used for Dosepoint specification:
Dosepoint(),
add_Dosepoint(),
modify_Dosepoint()
Functions used for StParm specification:
StParm(),
add_StParm(),
create_ModelPD(),
modify_StParm(),
modify_StParmCustom(),
remove_StParm()
Functions used for Observation specification:
Observation(),
ObservationCustom(),
Sigmas(),
create_ModelPD(),
modify_Observation(),
remove_Observation()
Functions used for Omega specification:
Omega(),
create_ModelPD(),
modify_Omega()
Functions used for Theta specification:
InitialEstimate(),
Theta(),
create_ModelPD(),
modify_Theta()
Functions used for Covariate specification:
Covariate(),
add_Covariate(),
create_ModelPD(),
remove_Covariate()
# Get PK model set with default options PMLParametersSets <- create_ModelPK() #' # Get PK Model search with custom options: # will create 2 PML Parameters Sets with 2 and 3 compartments, # with Absorption First-Order and Gamma accordingly: ModelPKSearch <- create_ModelPK(CompartmentsNumber = c(2, 3), Parameterization = "Micro", Absorption = c("First-Order", "Gamma"), ByVector = TRUE, ClosedForm = TRUE) # Next example will create a set of 4 PMLParametersSets: # a combination of models with 2 and 3 compartments and First-Order and Gamma Absorption PMLParametersSets <- create_ModelPK(CompartmentsNumber = c(2, 3), Absorption = c("First-Order", "Gamma"), ByVector = FALSE, ClosedForm = FALSE) # Create 2 PML Parameters Sets with elimination compartment and fraction excreted # and add zero order absorption to the main dosepoint of the PML Structure # with infusion PMLParametersSets <- create_ModelPK(CompartmentsNumber = 1, Absorption = c("Intravenous", "Gamma"), EliminationCpt = TRUE, FractionExcreted = TRUE, duration = StParm(StParmName = "Duration", OmegaStParm = Omega(State = "None")), PMLStructure = "PK1IVCEF") # Create 4 PML Parameters Sets, then modify `Cl` structural parameter for all sets, # with 2 initial estimates sets to be searched, # add `tlag` as a structural parameter `Tlag` to 1 compartment First-Order PML parameters set, # change `tvKa` Theta initial estimate, # change `nV` Omega initial estimate, # change `CObs` Observation sigmas, # add structural parameter `Rate` for 1 compartment Weibull Parameters set, # add `Weight` covariate for all structural parameters to be searched. PMLParametersSets <- create_ModelPK( CompartmentsNumber = 1, Absorption = c("First-Order", "Weibull"), ByVector = FALSE, Cl = StParm( StParmName = "Cl", Type = "LogNormal2", ThetaStParm = Theta(Name = "tvCl", InitialEstimates = InitialEstimate(c(-Inf, 0.2, Inf), c(0, 3, 10))) ), tlag = StParm( StParmName = "Tlag", State = "Searched", PMLStructure = "PK1FOC", Covariates = list( Age = Covariate( Name = "Age", Type = "Categorical", State = "Searched", Direction = "Backward", Center = "None", Categories = c(1, 2, 3) ) ) ), tvKa = Theta(Name = "tvKa", InitialEstimates = 10), nV = Omega(Name = "nV", InitialOmega = 0.1), CObs = Observation( ObservationName = "CObs", SigmasChosen = list( AdditiveMultiplicative = c(PropPart = 0.1, AddPart = 2), Proportional = 1 ) ), A1 = Dosepoint( DosepointName = "A1", rate = StParm(StParmName = "Rate"), PMLStructure = "PK1WC" ), Weight = Covariate( Name = "Weight", State = "Searched", Center = "Median" ) )# Get PK model set with default options PMLParametersSets <- create_ModelPK() #' # Get PK Model search with custom options: # will create 2 PML Parameters Sets with 2 and 3 compartments, # with Absorption First-Order and Gamma accordingly: ModelPKSearch <- create_ModelPK(CompartmentsNumber = c(2, 3), Parameterization = "Micro", Absorption = c("First-Order", "Gamma"), ByVector = TRUE, ClosedForm = TRUE) # Next example will create a set of 4 PMLParametersSets: # a combination of models with 2 and 3 compartments and First-Order and Gamma Absorption PMLParametersSets <- create_ModelPK(CompartmentsNumber = c(2, 3), Absorption = c("First-Order", "Gamma"), ByVector = FALSE, ClosedForm = FALSE) # Create 2 PML Parameters Sets with elimination compartment and fraction excreted # and add zero order absorption to the main dosepoint of the PML Structure # with infusion PMLParametersSets <- create_ModelPK(CompartmentsNumber = 1, Absorption = c("Intravenous", "Gamma"), EliminationCpt = TRUE, FractionExcreted = TRUE, duration = StParm(StParmName = "Duration", OmegaStParm = Omega(State = "None")), PMLStructure = "PK1IVCEF") # Create 4 PML Parameters Sets, then modify `Cl` structural parameter for all sets, # with 2 initial estimates sets to be searched, # add `tlag` as a structural parameter `Tlag` to 1 compartment First-Order PML parameters set, # change `tvKa` Theta initial estimate, # change `nV` Omega initial estimate, # change `CObs` Observation sigmas, # add structural parameter `Rate` for 1 compartment Weibull Parameters set, # add `Weight` covariate for all structural parameters to be searched. PMLParametersSets <- create_ModelPK( CompartmentsNumber = 1, Absorption = c("First-Order", "Weibull"), ByVector = FALSE, Cl = StParm( StParmName = "Cl", Type = "LogNormal2", ThetaStParm = Theta(Name = "tvCl", InitialEstimates = InitialEstimate(c(-Inf, 0.2, Inf), c(0, 3, 10))) ), tlag = StParm( StParmName = "Tlag", State = "Searched", PMLStructure = "PK1FOC", Covariates = list( Age = Covariate( Name = "Age", Type = "Categorical", State = "Searched", Direction = "Backward", Center = "None", Categories = c(1, 2, 3) ) ) ), tvKa = Theta(Name = "tvKa", InitialEstimates = 10), nV = Omega(Name = "nV", InitialOmega = 0.1), CObs = Observation( ObservationName = "CObs", SigmasChosen = list( AdditiveMultiplicative = c(PropPart = 0.1, AddPart = 2), Proportional = 1 ) ), A1 = Dosepoint( DosepointName = "A1", rate = StParm(StParmName = "Rate"), PMLStructure = "PK1WC" ), Weight = Covariate( Name = "Weight", State = "Searched", Center = "Median" ) )
Generates a list of parameters to be used in a pyDarwin run.
create_pyDarwinOptions( author = "", project_name = NULL, algorithm = c("GA", "EX", "MOGA", "MOGA3", "GP", "RF", "GBRT", "PSO"), GA = pyDarwinOptionsGA(), MOGA = pyDarwinOptionsMOGA(), PSO = pyDarwinOptionsPSO(), random_seed = 11, num_parallel = 4, num_generations = 6, population_size = 4, num_opt_chains = 4, exhaustive_batch_size = 100, crash_value = 99999999, penalty = pyDarwinOptionsPenalty(), effect_limit = -1, downhill_period = 2, num_niches = 2, niche_radius = 2, local_2_bit_search = TRUE, final_downhill_search = TRUE, local_grid_search = FALSE, max_local_grid_search_bits = 5, search_omega_blocks = FALSE, search_omega_bands = FALSE, individual_omega_search = TRUE, search_omega_sub_matrix = FALSE, max_omega_sub_matrix = 4, model_run_timeout = 1200, model_run_priority_class = c("below_normal", "normal"), postprocess = pyDarwinOptionsPostprocess(), keep_key_models = TRUE, keep_best_models = TRUE, rerun_key_models = FALSE, rerun_front_models = TRUE, use_saved_models = FALSE, saved_models_file = "{working_dir}/models0.json", saved_models_readonly = FALSE, remove_run_dir = FALSE, remove_temp_dir = FALSE, keep_files = c("dmp.txt", "posthoc.csv"), keep_extensions = NULL, use_system_options = TRUE, model_cache = "darwin.MemoryModelCache", model_run_man = c("darwin.LocalRunManager", "darwin.GridRunManager"), engine_adapter = c("nlme", "nonmem"), skip_running = FALSE, working_dir = NULL, data_dir = NULL, output_dir = "{working_dir}/output", temp_dir = NULL, key_models_dir = "{working_dir}/key_models", non_dominated_models_dir = "{working_dir}/non_dominated_models", nlme_dir = "C:/Program Files/Certara/NLME_Engine", gcc_dir = "C:/Program Files/Certara/mingw64", nmfe_path = NULL, rscript_path = file.path(normalizePath(R.home("bin")), "Rscript"), generic_grid_adapter = pyDarwinOptionsGridAdapter(), remote_run = FALSE, ... )create_pyDarwinOptions( author = "", project_name = NULL, algorithm = c("GA", "EX", "MOGA", "MOGA3", "GP", "RF", "GBRT", "PSO"), GA = pyDarwinOptionsGA(), MOGA = pyDarwinOptionsMOGA(), PSO = pyDarwinOptionsPSO(), random_seed = 11, num_parallel = 4, num_generations = 6, population_size = 4, num_opt_chains = 4, exhaustive_batch_size = 100, crash_value = 99999999, penalty = pyDarwinOptionsPenalty(), effect_limit = -1, downhill_period = 2, num_niches = 2, niche_radius = 2, local_2_bit_search = TRUE, final_downhill_search = TRUE, local_grid_search = FALSE, max_local_grid_search_bits = 5, search_omega_blocks = FALSE, search_omega_bands = FALSE, individual_omega_search = TRUE, search_omega_sub_matrix = FALSE, max_omega_sub_matrix = 4, model_run_timeout = 1200, model_run_priority_class = c("below_normal", "normal"), postprocess = pyDarwinOptionsPostprocess(), keep_key_models = TRUE, keep_best_models = TRUE, rerun_key_models = FALSE, rerun_front_models = TRUE, use_saved_models = FALSE, saved_models_file = "{working_dir}/models0.json", saved_models_readonly = FALSE, remove_run_dir = FALSE, remove_temp_dir = FALSE, keep_files = c("dmp.txt", "posthoc.csv"), keep_extensions = NULL, use_system_options = TRUE, model_cache = "darwin.MemoryModelCache", model_run_man = c("darwin.LocalRunManager", "darwin.GridRunManager"), engine_adapter = c("nlme", "nonmem"), skip_running = FALSE, working_dir = NULL, data_dir = NULL, output_dir = "{working_dir}/output", temp_dir = NULL, key_models_dir = "{working_dir}/key_models", non_dominated_models_dir = "{working_dir}/non_dominated_models", nlme_dir = "C:/Program Files/Certara/NLME_Engine", gcc_dir = "C:/Program Files/Certara/mingw64", nmfe_path = NULL, rscript_path = file.path(normalizePath(R.home("bin")), "Rscript"), generic_grid_adapter = pyDarwinOptionsGridAdapter(), remote_run = FALSE, ... )
author |
Character string: The name of the author. |
project_name |
Character string (optional): The name of the project. If not specified, pyDarwin will set its value to the name of the parent folder of the options file. |
algorithm |
Character string: One of EX, GA, MOGA, MOGA3, GP, RF, GBRT, PSO. See section Details below for more information. |
GA |
List: Options specific to the Genetic Algorithm (GA).
See |
MOGA |
List: Options specific to the Multi-Objective Genetic Algorithm
(MOGA or MOGA3). See |
PSO |
List: Options specific to the Particle Swarm Optimization (PSO).
See |
random_seed |
Positive integer: Seed for random number generation. |
num_parallel |
Positive integer: Number of models to execute in parallel, i.e., how many threads to create to handle model runs. Default: 4. |
num_generations |
Positive integer: Number of iterations or generations of the search algorithm to run. Not used/required for EX. Default: 6. |
population_size |
Positive integer: Number of models to create in every generation. Not used/required for EX. Default: 4. |
num_opt_chains |
Positive integer: Number of parallel processes to perform the "ask" step (to increase performance). Required only for GP, RF, and GBRT. Default: 4. |
exhaustive_batch_size |
Positive integer: Batch size for the EX (Exhaustive Search) algorithm. Default: 100. |
crash_value |
Positive real: Value of fitness or reward assigned when model output is not generated. Should be set larger than any anticipated completed model fitness. Default: 99999999. |
penalty |
List: Options specific to the penalty calculation.
See |
effect_limit |
Integer: Limits number of effects. Applicable only for NONMEM and GA/MOGA/MOGA3. If < 1, effect limit is turned off. Default: -1. |
downhill_period |
Integer: How often to run the downhill step. If < 1, no periodic downhill search will be performed. Default: 2. |
num_niches |
Integer: Used for GA and downhill. A penalty is assigned
for each model based on the number of similar models within a niche radius.
This penalty is applied only to the selection process (not to the fitness
of the model). The purpose is to ensure maintaining a degree of diversity
in the population. |
niche_radius |
Positive real: The radius of the niches. Used to define how similar pairs of models are, for Local search and GA sharing penalty. Default: 2. |
local_2_bit_search |
Logical: Whether to perform the two-bit local
search. Substantially increases search robustness. Done starting from
|
final_downhill_search |
Logical: Whether to perform a local search (1-bit and 2-bit) at the end of the global search. Default: TRUE. |
local_grid_search |
Logical: Whether to perform a local grid search during downhill. Default: FALSE. |
max_local_grid_search_bits |
Positive integer: Maximum number of bits to explore in the local grid search. Default: 5. |
search_omega_blocks |
Logical: Whether to perform search for block
omegas. Used only when |
search_omega_bands |
Logical: Whether to perform search for band
omegas. Used only when |
individual_omega_search |
Logical: If TRUE, every omega search block is handled individually. If FALSE, all search blocks have the same pattern. Default: TRUE. |
search_omega_sub_matrix |
Logical: Set to TRUE to search omega submatrix. Default: FALSE. |
max_omega_sub_matrix |
Integer: Maximum size of sub matrix to use in search. Default: 4. |
model_run_timeout |
Positive real: Time (seconds) after which the execution will be terminated, and the crash value assigned. Default: 1200. |
model_run_priority_class |
Character string (Windows only): Priority
class for child processes. Options are |
postprocess |
List: Options specific to postprocessing.
See |
keep_key_models |
Logical: Whether to save the best model from every
generation to |
keep_best_models |
Logical: If |
rerun_key_models |
Logical: Whether to re-run key models that lack output after the search. Default: FALSE. |
rerun_front_models |
Logical: Similar to |
use_saved_models |
Logical: Whether to restore saved Model Cache from file. Default: FALSE. |
saved_models_file |
Character string: The file from which to restore Model Cache. Default: "{working_dir}/models0.json". |
saved_models_readonly |
Logical: Do not overwrite the
|
remove_run_dir |
Logical: If TRUE, delete the entire model run directory, otherwise only unnecessary files. Default: FALSE. |
remove_temp_dir |
Logical: Whether to delete the entire |
keep_files |
Character vector (optional): List of exact file names to
keep when cleaning up run directories.
Default is |
keep_extensions |
Character vector (optional): List of file extensions (without dot) to keep. Default: NULL. |
use_system_options |
Logical: Whether to override options with environment-specific values. Default: TRUE. |
model_cache |
Character string: ModelCache subclass to be used. Default: "darwin.MemoryModelCache". |
model_run_man |
Character string: ModelRunManager subclass to be used. Options: "darwin.LocalRunManager" (default), "darwin.GridRunManager". |
engine_adapter |
Character string: ModelEngineAdapter subclass. Options: "nlme" (default), "nonmem". |
skip_running |
Logical: If TRUE, no actual NM/NLME runs will be performed. Default: FALSE. |
working_dir |
Character string (optional): Project's working directory. |
data_dir |
Character string (optional): Directory for datasets. |
output_dir |
Character string: Directory for pyDarwin output. Default: "{working_dir}/output". |
temp_dir |
Character string (optional): Parent directory for model run subdirectories. |
key_models_dir |
Character string: Directory where key/best models will be saved. Default: "{working_dir}/key_models". |
non_dominated_models_dir |
Character string: Directory where non-dominated models will be saved (typically for MOGA/MOGA3). Default: "{working_dir}/non_dominated_models". |
nlme_dir |
Character string (optional): Directory for NLME Engine installation. |
gcc_dir |
Character string (optional): Directory for Mingw-w64 compiler. |
nmfe_path |
Character string (optional): Path to NONMEM execution command. |
rscript_path |
Character string (optional): Path to Rscript executable. |
generic_grid_adapter |
List: Options for grid execution.
See |
remote_run |
Logical: Indicates if pyDarwin execution is for a remote
host. Default: |
... |
Additional parameters. |
The algorithm parameter specifies the search algorithm. The algorithm “MOGA” and “MOGA3” are used for multi-objective optimization: "MOGA" uses NSGA-II (see the documentation at https://pymoo.org/algorithms/moo/nsga2.html?highlight=nsga%20ii), and "MOGA3" uses NSGA-III (see the documentation at https://pymoo.org/algorithms/moo/nsga3.html?highlight=nsga%20ii). For MOGA3, the objectives and constraints must be defined and returned by postprocessing scripts (post_run_r_code or post_run_python_code) in a specific format:
R scripts should return a list of two vectors: the first vector is for the objectives and the second one is for the constraints. If no constraints, the second vector should be empty.
Python scripts should return a tuple of two lists: the first list is for the objectives and the second one is for the constraints). If no constraints, the second list should be empty.
Other algorithms include "EX" (Exhaustive), "GA" (Genetic Algorithm), "GP" (Gaussian Process), "RF" (Random Forest), "GBRT" (Gradient Boosted Random Tree), and "PSO" (Particle Swarm Optimization).
Please see pyDarwin documentation for complete details on all options.
A list of pyDarwin options.
# Basic options with GA ga_opts <- create_pyDarwinOptions(author = "Jane Doe", algorithm = "GA") # Options for MOGA (NSGA-II) # pyDarwin internally uses 2 objectives; postprocessing for objectives is not used by pyDarwin. moga_opts_nsga2 <- create_pyDarwinOptions( author = "J. Doe", project_name = "MOGA_Test_NSGA2", algorithm = "MOGA", # NSGA-II MOGA = pyDarwinOptionsMOGA(), # Default MOGA options are suitable population_size = 50, num_generations = 100, engine_adapter = "nonmem", nmfe_path = "/opt/NONMEM/nm75/run/nmfe75" ) # Options for MOGA3 (NSGA-III with 3 objectives, 1 constraint via R postprocessing) moga_opts_nsga3_custom <- pyDarwinOptionsMOGA( objectives = 3, names = c("AIC", "NumEffects", "RunTime"), # Example custom names constraints = 1, partitions = 10 # Custom partitions ) main_opts_nsga3 <- create_pyDarwinOptions( author = "J. Doe", project_name = "MOGA_Test_NSGA3", algorithm = "MOGA3", # NSGA-III MOGA = moga_opts_nsga3_custom, population_size = 60, # NSGA-III population size might need adjustment num_generations = 100, postprocess = pyDarwinOptionsPostprocess( # Required for MOGA3 use_r = TRUE, post_run_r_code = "{project_dir}/moga3_postprocess.R" ), engine_adapter = "nonmem", nmfe_path = "/opt/NONMEM/nm75/run/nmfe75" )# Basic options with GA ga_opts <- create_pyDarwinOptions(author = "Jane Doe", algorithm = "GA") # Options for MOGA (NSGA-II) # pyDarwin internally uses 2 objectives; postprocessing for objectives is not used by pyDarwin. moga_opts_nsga2 <- create_pyDarwinOptions( author = "J. Doe", project_name = "MOGA_Test_NSGA2", algorithm = "MOGA", # NSGA-II MOGA = pyDarwinOptionsMOGA(), # Default MOGA options are suitable population_size = 50, num_generations = 100, engine_adapter = "nonmem", nmfe_path = "/opt/NONMEM/nm75/run/nmfe75" ) # Options for MOGA3 (NSGA-III with 3 objectives, 1 constraint via R postprocessing) moga_opts_nsga3_custom <- pyDarwinOptionsMOGA( objectives = 3, names = c("AIC", "NumEffects", "RunTime"), # Example custom names constraints = 1, partitions = 10 # Custom partitions ) main_opts_nsga3 <- create_pyDarwinOptions( author = "J. Doe", project_name = "MOGA_Test_NSGA3", algorithm = "MOGA3", # NSGA-III MOGA = moga_opts_nsga3_custom, population_size = 60, # NSGA-III population size might need adjustment num_generations = 100, postprocess = pyDarwinOptionsPostprocess( # Required for MOGA3 use_r = TRUE, post_run_r_code = "{project_dir}/moga3_postprocess.R" ), engine_adapter = "nonmem", nmfe_path = "/opt/NONMEM/nm75/run/nmfe75" )
Create a new Dosepoint object and validate it
Dosepoint( DosepointName = "A1", State = "Present", tlag = c(), bioavail = c(), duration = c(), rate = c(), PMLStructure = character() )Dosepoint( DosepointName = "A1", State = "Present", tlag = c(), bioavail = c(), duration = c(), rate = c(), PMLStructure = character() )
DosepointName |
A character string giving the name of the Dosepoint. |
State |
A character string giving the state of the Dosepoint, must be one of "None", "Present", "Searched". Default is "Present". |
tlag |
An optional parameter for the time lag. Can be an
|
bioavail |
An optional parameter for bioavailability. Can be an
|
duration |
An optional parameter for the duration of infusion. Can be an
|
rate |
An optional parameter for the rate of infusion. Can be an
|
PMLStructure |
A character string that indicates a specific PML structure this Dosepoint definition should be associated with. |
A new Dosepoint object.
list_Dosepoints(), add_Dosepoint(), modify_Dosepoint(), StParm(), Expression()
Functions used for Dosepoint specification:
add_Dosepoint(),
create_ModelPK(),
modify_Dosepoint()
# Using StParm objects TlagStParm <- StParm("Tlag", Type = "LogNormal", ThetaStParm = Theta(Name = "tvTlag", InitialEstimates = 0.1)) FStParm <- StParm("F", ThetaStParm = Theta(Name = "tvF")) # Assuming Theta exists dp1 <- Dosepoint(DosepointName = "GutInput", State = "Present", tlag = TlagStParm, bioavail = FStParm) # Using Expression objects dp2 <- Dosepoint(DosepointName = "Infusion", rate = Expression("RateVal", ContainedStParms = list(StParm("RateVal", ThetaStParm = Theta("tvRateVal"))))) # Using a character string (will be converted to Expression internally) dp3 <- Dosepoint(DosepointName = "Bolus", bioavail = "SystemicF") # Converted to Expression("SystemicF")# Using StParm objects TlagStParm <- StParm("Tlag", Type = "LogNormal", ThetaStParm = Theta(Name = "tvTlag", InitialEstimates = 0.1)) FStParm <- StParm("F", ThetaStParm = Theta(Name = "tvF")) # Assuming Theta exists dp1 <- Dosepoint(DosepointName = "GutInput", State = "Present", tlag = TlagStParm, bioavail = FStParm) # Using Expression objects dp2 <- Dosepoint(DosepointName = "Infusion", rate = Expression("RateVal", ContainedStParms = list(StParm("RateVal", ThetaStParm = Theta("tvRateVal"))))) # Using a character string (will be converted to Expression internally) dp3 <- Dosepoint(DosepointName = "Bolus", bioavail = "SystemicF") # Converted to Expression("SystemicF")
Represents a PML expression that can include text and structural parameters (StParm). This is used for arguments like tlag, bioavail, duration, or rate in Dosepoint.
Expression( ExpressionText = character(), ContainedStParms = list(), State = "Present" )Expression( ExpressionText = character(), ContainedStParms = list(), State = "Present" )
ExpressionText |
Character string. The primary textual representation of the expression (e.g., "1-F", "Tlag", "Rate * exp(Effect)"). |
ContainedStParms |
List. A list containing any StParm objects that are
referenced by or associated with this |
State |
Character string. The state of the expression and the associated structural parameters, controlling its inclusion or search status in the model. Must be one of 'Present', 'None', or 'Searched'. |
A new object of class Expression, which is a list containing the
provided arguments (ExpressionText, ContainedStParms, State).
PMLParametersSets <- get_PMLParametersSets(CompartmentsNumber = c(1, 2, 3), Absorption = c("First-Order")) # add dosepoint PMLParametersSets <- add_Dosepoint(PMLParametersSets, DosepointName = "A1", bioavail = Expression("1 - Fa"), duration = Expression("Tlag", ContainedStParms = list(StParm("Tlag"))))PMLParametersSets <- get_PMLParametersSets(CompartmentsNumber = c(1, 2, 3), Absorption = c("First-Order")) # add dosepoint PMLParametersSets <- add_Dosepoint(PMLParametersSets, DosepointName = "A1", bioavail = Expression("1 - Fa"), duration = Expression("Tlag", ContainedStParms = list(StParm("Tlag"))))
This function retrieves the model terms that can be mapped from a set of PML models.
get_ModelTermsToMap(PMLParametersSets)get_ModelTermsToMap(PMLParametersSets)
PMLParametersSets |
An object of class "PMLModels" containing PML model parameters. |
A list with two elements: "Required" and "Optional," representing the model terms that can be mapped.
create_ModelPK() create_ModelPD() create_CustomSpace()
# Load your PMLModels object PMLParametersSets <- create_ModelPK( Absorption = c("First-Order", "Weibull"), CObs = Observation( ObservationName = "CObs", BQL = TRUE), A1 = Dosepoint( DosepointName = "A1", rate = StParm(StParmName = "Rate")), Weight = Covariate( Name = "Weight", Center = "Median") ) # Get the model terms to map terms_to_map <- get_ModelTermsToMap(PMLParametersSets) print(terms_to_map$Required) print(terms_to_map$Optional)# Load your PMLModels object PMLParametersSets <- create_ModelPK( Absorption = c("First-Order", "Weibull"), CObs = Observation( ObservationName = "CObs", BQL = TRUE), A1 = Dosepoint( DosepointName = "A1", rate = StParm(StParmName = "Rate")), Weight = Covariate( Name = "Weight", Center = "Median") ) # Get the model terms to map terms_to_map <- get_ModelTermsToMap(PMLParametersSets) print(terms_to_map$Required) print(terms_to_map$Optional)
This function creates an object of class InitialEstimate that contains
initial parameter estimates for a model Theta(). The estimates can be
passed to the function as a single numeric value or as a vector of length
three containing lower bound, estimate, and upper bound. If multiple sets of
estimates are required, they can be passed as additional arguments, each
separated by commas.
InitialEstimate(Initial = numeric(), ...)InitialEstimate(Initial = numeric(), ...)
Initial |
Numeric. Initial estimate for the model parameter. |
... |
Additional initial estimate(s) for the model parameter. |
An object of class InitialEstimate.
Functions used for Theta specification:
Theta(),
create_ModelPD(),
create_ModelPK(),
modify_Theta()
InitialEstimate(1) InitialEstimate(c(0, 1, Inf), c(-Inf, 2, 10))InitialEstimate(1) InitialEstimate(c(0, 1, Inf), c(-Inf, 2, 10))
This function lists the names of covariates in a given set of PMLParametersSets.
list_Covariates(PMLParametersSets, IncludeAll = FALSE, IncludeCustom = TRUE)list_Covariates(PMLParametersSets, IncludeAll = FALSE, IncludeCustom = TRUE)
PMLParametersSets |
A list of PML parameters sets ( |
IncludeAll |
Logical. Should the names of covariates with |
IncludeCustom |
Logical. Should the names of |
A character vector containing the names of covariates.
add_Covariate() remove_Covariate() Covariate()
PMLParametersSets <- get_PMLParametersSets() PMLParametersSets <- add_Covariate(PMLParametersSets, Name = "WT") list_Covariates(PMLParametersSets)PMLParametersSets <- get_PMLParametersSets() PMLParametersSets <- add_Covariate(PMLParametersSets, Name = "WT") list_Covariates(PMLParametersSets)
This function lists the names of dosepoints in a given set of PMLParametersSets.
list_Dosepoints(PMLParametersSets, IncludeAll = FALSE, IncludeCustom = TRUE)list_Dosepoints(PMLParametersSets, IncludeAll = FALSE, IncludeCustom = TRUE)
PMLParametersSets |
A list of PML parameters sets ( |
IncludeAll |
Logical. Should the names of dosepoints with |
IncludeCustom |
Logical. Should the names of custom |
A character vector containing the names of dosepoints
PMLParametersSets <- get_PMLParametersSets( Absorption = c("First-Order", "Gamma")) list_Dosepoints(PMLParametersSets)PMLParametersSets <- get_PMLParametersSets( Absorption = c("First-Order", "Gamma")) list_Dosepoints(PMLParametersSets)
This function lists the names of Observations in a given PMLModels class
instance.
list_Observations( PMLParametersSets, IncludeCustom = TRUE, ObservationsOnly = TRUE )list_Observations( PMLParametersSets, IncludeCustom = TRUE, ObservationsOnly = TRUE )
PMLParametersSets |
A list of PML parameters sets ( |
IncludeCustom |
Logical. Should the names of responses ( |
ObservationsOnly |
Logical. If |
A character vector containing the names of Observations
Observation() modify_Observation() remove_Observation()
PMLParametersSets <- create_ModelPK( Absorption = c("First-Order", "Gamma"), EliminationCpt = c(TRUE, FALSE)) list_Observations(PMLParametersSets)PMLParametersSets <- create_ModelPK( Absorption = c("First-Order", "Gamma"), EliminationCpt = c(TRUE, FALSE)) list_Observations(PMLParametersSets)
This function lists the unique names of Omega parameters in a given set.
list_Omegas(PMLParametersSets, IncludeAll = FALSE, IncludeCustom = TRUE)list_Omegas(PMLParametersSets, IncludeAll = FALSE, IncludeCustom = TRUE)
PMLParametersSets |
|
IncludeAll |
Logical. Whether should the omega names to be inlcuded from
structural parameters, covariates or omegas with a |
IncludeCustom |
Logical. Should the names of custom |
A character vector containing the unique names of Omega parameters.
PMLParametersSets <- create_ModelPK() list_Omegas(PMLParametersSets)PMLParametersSets <- create_ModelPK() list_Omegas(PMLParametersSets)
This function lists the names of structural parameters in a given set of PMLParametersSets.
list_StParms(PMLParametersSets, IncludeAll = FALSE, IncludeCustom = TRUE)list_StParms(PMLParametersSets, IncludeAll = FALSE, IncludeCustom = TRUE)
PMLParametersSets |
A list of PML parameters sets ( |
IncludeAll |
Logical. Should the names of structural parameters with
|
IncludeCustom |
Logical. Should the names of custom |
A character vector containing the names of structural parameters.
PMLParametersSets <- get_PMLParametersSets() list_StParms(PMLParametersSets)PMLParametersSets <- get_PMLParametersSets() list_StParms(PMLParametersSets)
This function lists the unique names of Theta parameters in a given set.
list_Thetas(PMLParametersSets, IncludeAll = FALSE, IncludeCustom = TRUE)list_Thetas(PMLParametersSets, IncludeAll = FALSE, IncludeCustom = TRUE)
PMLParametersSets |
|
IncludeAll |
Logical. Whether should the Theta names to be inlcuded from
structural parameters, covariates or thetas with a |
IncludeCustom |
Logical. Should the names of custom |
A character vector containing the unique names of Theta parameters.
PMLParametersSets <- create_ModelPD() list_Thetas(PMLParametersSets)PMLParametersSets <- create_ModelPD() list_Thetas(PMLParametersSets)
Modify Dosepoint in PML models
modify_Dosepoint( PMLParametersSets, DosepointName, tlag, bioavail, duration, rate, PMLStructures = NULL )modify_Dosepoint( PMLParametersSets, DosepointName, tlag, bioavail, duration, rate, PMLStructures = NULL )
PMLParametersSets |
A list of PML parameters sets ( |
DosepointName |
A character string giving the name of the Dosepoint. |
tlag |
An optional parameter for the time lag. Can be an
|
bioavail |
An optional parameter for bioavailability. Can be an
|
duration |
An optional parameter for the duration of infusion. Can be an
|
rate |
An optional parameter for the rate of infusion. Can be an
|
PMLStructures |
Character or character vector specifying names of PML
structures in which the dosepoint statement will be modified. For the
naming convention of PMLStructures, see Details section of
|
This function can only be used to modify the structural parameters
in the built-in models (i.e., created using either create_ModelEmax() or
create_ModelPK()).
An updated list of PML models (PMLModels class instance) matching
the specified options.
list_Dosepoints(), add_Dosepoint()
Functions used for Dosepoint specification:
Dosepoint(),
add_Dosepoint(),
create_ModelPK()
PMLParametersSets <- get_PMLParametersSets(CompartmentsNumber = c(1, 2, 3)) # update structural paramter type PMLParametersSetsVMod <- modify_Dosepoint(PMLParametersSets, DosepointName = "A1", tlag = StParm(StParmName = "Tlag", State = "Searched"))PMLParametersSets <- get_PMLParametersSets(CompartmentsNumber = c(1, 2, 3)) # update structural paramter type PMLParametersSetsVMod <- modify_Dosepoint(PMLParametersSets, DosepointName = "A1", tlag = StParm(StParmName = "Tlag", State = "Searched"))
Modify Observation class in PML models
modify_Observation( PMLParametersSets, ObservationName, SigmasChosen, BQL, BQLValue, Frozen, ResetObs, Covariates, PMLStructures = NULL )modify_Observation( PMLParametersSets, ObservationName, SigmasChosen, BQL, BQLValue, Frozen, ResetObs, Covariates, PMLStructures = NULL )
PMLParametersSets |
A list of PML parameters sets ( |
ObservationName |
A character string giving the name of the Observation. |
SigmasChosen |
a Sigmas class instance or a list specifying the chosen sigma values for different error models. 0s are treated as no values. Inside Observation class it is transormed and kept as Sigmas class. The list could contain the following error models:
|
BQL |
A logical value indicating whether the dataset contains BQL values and they should be taken into account (M3 method). |
BQLValue |
An optional numeric positive value of static LLOQ. Applicable
only when BQL argument is |
Frozen |
A logical value indicating if the standard deviation (Stdev) is frozen. |
ResetObs |
A logical value indicating if the Observation variable should
be reset to 0 after observation ( |
Covariates |
A list of covariates ( |
PMLStructures |
Character or character vector specifying names of PML
structures in which the observation will be modified. For the naming
convention of PMLStructures, see Details section of
|
This function can only be used to modify the structural parameters
in the built-in models (i.e., created using either create_ModelEmax() or
create_ModelPK()).
An updated list of PML models (PMLModels class instance) matching
the specified options.
Functions used for Observation specification:
Observation(),
ObservationCustom(),
Sigmas(),
create_ModelPD(),
create_ModelPK(),
remove_Observation()
PMLParametersSets <- create_ModelPK(CompartmentsNumber = c(1, 2, 3)) # update structural paramter type PMLParametersSetsVMod <- modify_Observation( PMLParametersSets, ObservationName = "CObs", SigmasChosen = Sigmas(Proportional = 0, AdditiveMultiplicative = list(PropPart = 0.1, AddPart = 10))) print(PMLParametersSetsVMod)PMLParametersSets <- create_ModelPK(CompartmentsNumber = c(1, 2, 3)) # update structural paramter type PMLParametersSetsVMod <- modify_Observation( PMLParametersSets, ObservationName = "CObs", SigmasChosen = Sigmas(Proportional = 0, AdditiveMultiplicative = list(PropPart = 0.1, AddPart = 10))) print(PMLParametersSetsVMod)
This function allows to modify Omega parameters in a list of PML models
(PMLModels class instance created by get_PMLParametersSets()).
modify_Omega( PMLParametersSets, Name, InitialOmega, State, Frozen, PMLStructures = NULL )modify_Omega( PMLParametersSets, Name, InitialOmega, State, Frozen, PMLStructures = NULL )
PMLParametersSets |
A list of PML parameters sets ( |
Name |
A character string specifying the name of the Omega. |
InitialOmega |
Numeric specifying the initial value of the Omega. Default value is 1. |
State |
Character specifying the presence of the Omega. Possible values are:
|
Frozen |
A logical value indicating whether the Omega is frozen or not. |
PMLStructures |
Character or character vector specifying names of PML
structures in which the Omega will be modified. For the naming convention
of PMLStructures, see Details section of |
If the specified Omega does not exist in the PML models, a warning will be issued, and no modifications will be made.
The current functionality does not support modifying custom omegas (ranefs) that are defined within the PML code of custom model spaces.
An updated list of PML models (PMLModels class instance) matching
the specified options.
Functions used for Omega specification:
Omega(),
create_ModelPD(),
create_ModelPK()
PMLParametersSets12 <- create_ModelPK(CompartmentsNumber = c(1, 2)) # Modify an Omega parameter named "nV" with new Initial Estimate and # Frozen flag PMLParametersSets12Mod1 <- modify_Omega(PMLParametersSets12, Name = "nV", InitialOmega = 0.3, State = "Present", Frozen = TRUE, PMLStructures = "PK1IVC") print(PMLParametersSets12Mod1)PMLParametersSets12 <- create_ModelPK(CompartmentsNumber = c(1, 2)) # Modify an Omega parameter named "nV" with new Initial Estimate and # Frozen flag PMLParametersSets12Mod1 <- modify_Omega(PMLParametersSets12, Name = "nV", InitialOmega = 0.3, State = "Present", Frozen = TRUE, PMLStructures = "PK1IVC") print(PMLParametersSets12Mod1)
Modify structural parameter in PML models set
modify_StParm( PMLParametersSets, StParmName, Type = "LogNormal", State = "Present", ThetaStParm, OmegaStParm, Covariates, PMLStructures = NULL )modify_StParm( PMLParametersSets, StParmName, Type = "LogNormal", State = "Present", ThetaStParm, OmegaStParm, Covariates, PMLStructures = NULL )
PMLParametersSets |
A list of PML parameters sets ( |
StParmName |
Character specifying the name of the structural parameter to be modified. |
Type |
Character specifying the type of the structural parameter. Options are
|
State |
character string that indicates the presence of the structural parameter. Options are:
|
ThetaStParm |
A Theta class instance inside the structural parameter. If
not given, the associated Theta will be automatically created with its name
set to "tv" + |
OmegaStParm |
An Omega class instance inside the structural parameter.
If not given, the associated Omega will be automatically created with its
name set to "n" + |
Covariates |
A list of covariates ( |
PMLStructures |
Character or character vector specifying names of PML
structures to which the structural parameter will be added. For the naming
convention of PMLStructures, see Details section of
|
This function can only be used to modify the structural parameters
in the built-in models (i.e., created using either create_ModelEmax() or
create_ModelPK()) or in the custom models if they are added with
add_StParm().
An updated list of PML models (PMLModels class instance) matching
the specified options.
Functions used for StParm specification:
StParm(),
add_StParm(),
create_ModelPD(),
create_ModelPK(),
modify_StParmCustom(),
remove_StParm()
PMLParametersSets <- get_PMLParametersSets(CompartmentsNumber = c(1, 2, 3)) # update structural parameter type PMLParametersSetsVMod <- modify_StParm(PMLParametersSets, StParmName = "V", Type = "LogitNormal")PMLParametersSets <- get_PMLParametersSets(CompartmentsNumber = c(1, 2, 3)) # update structural parameter type PMLParametersSetsVMod <- modify_StParm(PMLParametersSets, StParmName = "V", Type = "LogitNormal")
Modify custom structural parameter in PML spaces
modify_StParmCustom( PMLParametersSets, StParmName, Type, State, ThetaStParm, OmegaStParm, Covariates, PMLStructures = NULL )modify_StParmCustom( PMLParametersSets, StParmName, Type, State, ThetaStParm, OmegaStParm, Covariates, PMLStructures = NULL )
PMLParametersSets |
A list of PML parameters sets ( |
StParmName |
Character specifying the name of the structural parameter to be added. |
Type |
Character specifying the type of the structural parameter. Options are
|
State |
character string that indicates the presence of the structural parameter. Options are:
|
ThetaStParm |
A Theta class instance inside the structural parameter. If
not given, the associated Theta will be automatically created with its name
set to "tv" + |
OmegaStParm |
An Omega class instance inside the structural parameter.
If not given, the associated Omega will be automatically created with its
name set to "n" + |
Covariates |
A list of covariates ( |
PMLStructures |
Character or character vector specifying names of PML
structures to which the structural parameter will be added. For the naming
convention of PMLStructures, see Details section of
|
This function can be applied to the custom models. It allows modification of custom structural parameters defined in the PML code of these spaces.
When modifying a custom structural parameter, the corresponding Stparm
statement is removed from the PML code, and the updated parameter is added
back as a StParm class using the provided arguments. Similarly, associated
fixef and ranef statements related to the custom structural parameter are
removed.
Please note that this function is specifically designed for modifying custom
structural parameters. For non-custom parameters, use modify_StParm().
An updated list of PML models (PMLModels class instance) matching
the specified options.
Dosepoint() list_StParms() modify_StParm()
Functions used for StParm specification:
StParm(),
add_StParm(),
create_ModelPD(),
create_ModelPK(),
modify_StParm(),
remove_StParm()
# Modify the custom structural parameter 'Cl': OneCpt_CustomCode <- paste0( "\nderiv(A1 = - Cl * C)", "\ndosepoint(A1)", "\ndosepoint2(A1, tlag = 12)", "\nC = A1 / V", "\nerror(CEps = 0.01)", "\nobserve(CObs = C + CEps * sqrt(1 + C^2 * (CMultStdev/sigma())^2), bql = 0.01)", "\nstparm(V = tvV * exp(nV))", "\nstparm(Cl = tvCl * exp(nCl))", "\nstparm(CMultStdev = tvCMultStdev)", "\nfixef(tvV = c(, 5, ))", "\nfixef(tvCl = c(, 1, ))", "\nfixef(tvCMultStdev = c(, 0.1, ))", "\nranef(diag(nV) = c(1))", "\nranef(diag(nCl) = c(1))\n" ) OneCpt_CustomCode <- modify_StParmCustom( create_CustomSpace(OneCpt_CustomCode), StParmName = "Cl", Type = "Normal")# Modify the custom structural parameter 'Cl': OneCpt_CustomCode <- paste0( "\nderiv(A1 = - Cl * C)", "\ndosepoint(A1)", "\ndosepoint2(A1, tlag = 12)", "\nC = A1 / V", "\nerror(CEps = 0.01)", "\nobserve(CObs = C + CEps * sqrt(1 + C^2 * (CMultStdev/sigma())^2), bql = 0.01)", "\nstparm(V = tvV * exp(nV))", "\nstparm(Cl = tvCl * exp(nCl))", "\nstparm(CMultStdev = tvCMultStdev)", "\nfixef(tvV = c(, 5, ))", "\nfixef(tvCl = c(, 1, ))", "\nfixef(tvCMultStdev = c(, 0.1, ))", "\nranef(diag(nV) = c(1))", "\nranef(diag(nCl) = c(1))\n" ) OneCpt_CustomCode <- modify_StParmCustom( create_CustomSpace(OneCpt_CustomCode), StParmName = "Cl", Type = "Normal")
This function allows to modify Theta parameter in a list of PML models
(PMLModels class instance created by create_ModelPK() or create_ModelPD).
modify_Theta( PMLParametersSets, Name, InitialEstimates, Frozen, PMLStructures = NULL )modify_Theta( PMLParametersSets, Name, InitialEstimates, Frozen, PMLStructures = NULL )
PMLParametersSets |
A list of PML parameters sets ( |
Name |
Character specifying the name of the Theta to be modified. |
InitialEstimates |
An |
Frozen |
A logical value indicating whether the Theta will be estimated or not. |
PMLStructures |
Character or character vector specifying names of PML
structures in which the |
If the specified Theta does not exist in the PML models, a warning will be issued, and no modifications will be made. Thetas associated with structural parameters in the proportional part of MixRatio and Additive+Proportional error models can also be modified.
The current functionality does not support modifying custom thetas (fixefs) that are defined within the PML code of custom model spaces.
An updated list of PML models (PMLModels class instance) matching
the specified options.
Functions used for Theta specification:
InitialEstimate(),
Theta(),
create_ModelPD(),
create_ModelPK()
PMLParametersSets <- create_ModelPK(CompartmentsNumber = c(1, 2)) # Modify a Theta parameter named "tvV" with new Initial Estimates and # Frozen flag PMLParametersSetsMod1 <- modify_Theta(PMLParametersSets, Name = "tvV", Frozen = TRUE, InitialEstimates = 0.3) print(PMLParametersSetsMod1) PMLParametersSetsMod2 <- add_StParm(PMLParametersSets = PMLParametersSetsMod1, StParmName = "Duration", State = "Searched", PMLStructures = "PK2IVC", DosepointArgName = "duration") PMLParametersSetsMod3 <- modify_Theta(PMLParametersSets = PMLParametersSetsMod2, Name = "tvDuration", InitialEstimates = c(2, 4, Inf)) print(PMLParametersSetsMod3)PMLParametersSets <- create_ModelPK(CompartmentsNumber = c(1, 2)) # Modify a Theta parameter named "tvV" with new Initial Estimates and # Frozen flag PMLParametersSetsMod1 <- modify_Theta(PMLParametersSets, Name = "tvV", Frozen = TRUE, InitialEstimates = 0.3) print(PMLParametersSetsMod1) PMLParametersSetsMod2 <- add_StParm(PMLParametersSets = PMLParametersSetsMod1, StParmName = "Duration", State = "Searched", PMLStructures = "PK2IVC", DosepointArgName = "duration") PMLParametersSetsMod3 <- modify_Theta(PMLParametersSets = PMLParametersSetsMod2, Name = "tvDuration", InitialEstimates = c(2, 4, Inf)) print(PMLParametersSetsMod3)
This function creates a new instance of Observation object and validates it.
Observation( ObservationName = "CObs", SigmasChosen = Sigmas(Proportional = 0.1), BQL = FALSE, BQLValue = NA, Frozen = FALSE, ResetObs = FALSE, Covariates = list(), PMLStructure = character() )Observation( ObservationName = "CObs", SigmasChosen = Sigmas(Proportional = 0.1), BQL = FALSE, BQLValue = NA, Frozen = FALSE, ResetObs = FALSE, Covariates = list(), PMLStructure = character() )
ObservationName |
A character string giving the name of the Observation. |
SigmasChosen |
a Sigmas class instance or a list specifying the chosen sigma values for different error models. 0s are treated as no values. Inside Observation class it is transormed and kept as Sigmas class. The list could contain the following error models:
|
BQL |
A logical value indicating whether the dataset contains BQL values and they should be taken into account (M3 method). |
BQLValue |
An optional numeric positive value of static LLOQ. Applicable
only when BQL argument is |
Frozen |
A logical value indicating if the standard deviation (Stdev) is frozen. |
ResetObs |
A logical value indicating if the Observation variable should
be reset to 0 after observation ( |
Covariates |
A list of covariates ( |
PMLStructure |
Character specifying the name of PML structure in which
the observation should be added. For the naming convention of
PMLStructures, see Details section of |
A new Observation object
Functions used for Observation specification:
ObservationCustom(),
Sigmas(),
create_ModelPD(),
create_ModelPK(),
modify_Observation(),
remove_Observation()
A0Obs <- Observation(ObservationName = "A0Obs", SigmasChosen = list(Additive = 2, Power = c(Stdev = 10, Power = 0.5)), Frozen = FALSE, ResetObs = TRUE, PMLStructure = "PK1FOC") CObs <- Observation("CObs", Frozen = TRUE, PMLStructure = "2Cpt")A0Obs <- Observation(ObservationName = "A0Obs", SigmasChosen = list(Additive = 2, Power = c(Stdev = 10, Power = 0.5)), Frozen = FALSE, ResetObs = TRUE, PMLStructure = "PK1FOC") CObs <- Observation("CObs", Frozen = TRUE, PMLStructure = "2Cpt")
This function creates a new instance of custom Observation object and validates it.
All PML responses are supported (observe, multi, LL, event, count, ordinal)
ObservationCustom( ObservationName = "CObs", Type = "observe", Statement = "", StatementNames = list(), Sigma = list(), Dobefore = c(), Doafter = c(), BQL = FALSE, BQLValue = NA, PMLStructure = character() )ObservationCustom( ObservationName = "CObs", Type = "observe", Statement = "", StatementNames = list(), Sigma = list(), Dobefore = c(), Doafter = c(), BQL = FALSE, BQLValue = NA, PMLStructure = character() )
ObservationName |
A character string giving the name of the Observation. |
Type |
One of the following: |
Statement |
A character string giving the RHS of response statement without |
StatementNames |
A character vector giving the names of variables used in the |
Sigma |
a list specifying the chosen sigma value Should be given only if
|
Dobefore |
A character string specifying the sequence of operations to be performed before current observation event. |
Doafter |
A character string specifying the sequence of operations to be performed after current observation event. |
BQL |
A logical value indicating whether the dataset contains BQL values and they should be taken into account (M3 method). |
BQLValue |
An optional numeric positive value of static LLOQ. Applicable
only when BQL argument is |
PMLStructure |
Character specifying the name of PML structure in which
the observation should be added. For the naming convention of
PMLStructures, see Details section of |
A new Observation object
Functions used for Observation specification:
Observation(),
Sigmas(),
create_ModelPD(),
create_ModelPK(),
modify_Observation(),
remove_Observation()
This function creates an Omega instance with the given parameters and validates it.
Omega( Name = character(), InitialOmega = 1, State = "Present", Frozen = FALSE, StParmName = character(), PMLStructure = character() )Omega( Name = character(), InitialOmega = 1, State = "Present", Frozen = FALSE, StParmName = character(), PMLStructure = character() )
Name |
A character string specifying the name of the Omega. |
InitialOmega |
Numeric specifying the initial value of the Omega. Default value is 1. |
State |
Character specifying the presence of the Omega. Possible values are:
|
Frozen |
A logical value indicating whether the Omega is frozen or not. |
StParmName |
A character string specifying the corresponding structural parameter name. |
PMLStructure |
PML structure current omega belongs to. |
An Omega instance.
Functions used for Omega specification:
create_ModelPD(),
create_ModelPK(),
modify_Omega()
nV <- Omega("nV")nV <- Omega("nV")
This function serves as a command-line argument parser that calls an
internal function (output_NLMETemplateInternal) to generate NLME (Non-Linear
Mixed Effects) model templates. It takes a series of "key=value" pairs,
processes a detailed JSON model specification, and outputs a model template
file and a corresponding tokens file, which can be used for model fitting.
output_NLMETemplate(args)output_NLMETemplate(args)
args |
A character vector where each element is a string in the format "key=value". The function parses these strings to set up the model generation process. The following keys are expected:
|
This function does not return a value to the R environment. It is executed for its side effect of writing two files:
A model template file to the location specified by template_path.
A tokens JSON file to the location specified by tokens_path.
The core logic is handled by the internal function output_NLMETemplateInternal.
The final file writing is performed by write_ModelTemplateTokens.
## Not run: # Example of the arguments that would be passed to the function. # In a real scenario, these might come from a command-line call. arguments <- c( "model_setup=./model_definition.json", "template_path=./template.txt", "tokens_path=./tokens.json", "data_path=./pk_data.csv", "author=Jane Doe", "description=2-compartment PK model with first-order absorption and linear elimination" ) # Execute the function with the defined arguments output_NLMETemplate(args = arguments) ## End(Not run)## Not run: # Example of the arguments that would be passed to the function. # In a real scenario, these might come from a command-line call. arguments <- c( "model_setup=./model_definition.json", "template_path=./template.txt", "tokens_path=./tokens.json", "data_path=./pk_data.csv", "author=Jane Doe", "description=2-compartment PK model with first-order absorption and linear elimination" ) # Execute the function with the defined arguments output_NLMETemplate(args = arguments) ## End(Not run)
This function generates the PML code representation of a custom space.
## S3 method for class 'CustomSpace' output(x, ...)## S3 method for class 'CustomSpace' output(x, ...)
x |
A |
... |
Additional arguments (not used). |
A character string containing the PML code.
This function allows you to set various options specific to the Genetic Algorithm (GA) in pyDarwin.
pyDarwinOptionsGA( elitist_num = 2, crossover_rate = 0.95, mutation_rate = 0.95, sharing_alpha = 0.1, selection = "tournament", selection_size = 2, crossover_operator = "cxOnePoint", mutate = "flipBit", attribute_mutation_probability = 0.1, niche_penalty = 20 )pyDarwinOptionsGA( elitist_num = 2, crossover_rate = 0.95, mutation_rate = 0.95, sharing_alpha = 0.1, selection = "tournament", selection_size = 2, crossover_operator = "cxOnePoint", mutate = "flipBit", attribute_mutation_probability = 0.1, niche_penalty = 20 )
elitist_num |
A positive integer specifying the number of best models from any generation to carry over, unchanged, to the next generation. Functions like the Hall of Fame in DEAP. Default: 2 |
crossover_rate |
A real value (between 0.0 and 1.0) specifying the fraction of mating pairs that will undergo crossover. Default: 0.95 |
mutation_rate |
A real value (between 0.0 and 1.0) specifying the probability that at least one bit in the genome will be “flipped”, 0 to 1, or 1 to 0. Default: 0.95 |
sharing_alpha |
A real value specifying the parameter of the niche penalty calculation. Default: 0.1 |
selection |
A string specifying the selection algorithm for the GA. Currently, only "tournament" is available. Default: "tournament" |
selection_size |
A positive integer specifying the number of “parents” to enter in the selection. 2 is highly recommended, experience with other values is very limited. Default: 2 |
crossover_operator |
A string specifying the algorithm for crossover. Only "cxOnePoint" (single-point crossover) is available. Default: "cxOnePoint" |
mutate |
A string specifying the algorithm for mutation. Currently, only "flipBit" is available. Default: "flipBit" |
attribute_mutation_probability |
A real value specifying the probability of any bit being mutated (real value between 0.0 and 1.0). Default: 0.1 |
niche_penalty |
A positive real value used for the calculation of the crowding penalty. The niche penalty is calculated by first finding the “distance matrix”, the pair-wise Mikowski distance from the present model to all other models. The “crowding” quantity is then calculated as the sum of: (distance/niche_radius)^sharing_alpha for all other models in the generation for which the Mikowski distance is less than the niche radius. Finally, the penalty is calculated as: exp((crowding-1)*niche_penalty)-1. The objective of using a niche penalty is to maintain diversity of models, to avoid premature convergence of the search by penalizing when models are too similar to other models in the current generation. Default: 20 |
An object of class "pyDarwinOptionsGA" containing the specified GA options.
# Create GA options with default values options <- pyDarwinOptionsGA() # Create GA options with custom values options <- pyDarwinOptionsGA(elitist_num = 4, crossover_rate = 0.9, mutation_rate = 0.8, sharing_alpha = 0.2)# Create GA options with default values options <- pyDarwinOptionsGA() # Create GA options with custom values options <- pyDarwinOptionsGA(elitist_num = 4, crossover_rate = 0.9, mutation_rate = 0.8, sharing_alpha = 0.2)
This function creates a list of grid adapter options for pyDarwin, which are used to configure the interaction between pyDarwin and grid computing environments.
pyDarwinOptionsGridAdapter( python_path = "~/darwin/venv/bin/python", submit_search_command = paste("qsub -b y -cwd -o {project_stem}_out.txt", "-e {project_stem}_err.txt -N '{project_name}'"), submit_command = paste("qsub -b y -o {results_dir}/{run_name}.out", "-e {results_dir}/{run_name}.err -N {job_name}"), submit_job_id_re = "Your job (\\w+) \\(\".+?\"\\) has been submitted", poll_command = "qstat -s z", poll_job_id_re = "^\\s+(\\w+)", poll_interval = 10, delete_command = "qdel {project_stem}-*" )pyDarwinOptionsGridAdapter( python_path = "~/darwin/venv/bin/python", submit_search_command = paste("qsub -b y -cwd -o {project_stem}_out.txt", "-e {project_stem}_err.txt -N '{project_name}'"), submit_command = paste("qsub -b y -o {results_dir}/{run_name}.out", "-e {results_dir}/{run_name}.err -N {job_name}"), submit_job_id_re = "Your job (\\w+) \\(\".+?\"\\) has been submitted", poll_command = "qstat -s z", poll_job_id_re = "^\\s+(\\w+)", poll_interval = 10, delete_command = "qdel {project_stem}-*" )
python_path |
Required. Path to Python interpreter, preferably to the instance of the interpreter located in the virtual environment where pyDarwin is deployed. The path must be available to all grid nodes that run jobs. |
submit_search_command |
Required. A command that submits a search job to the grid queue. This command is used for the entire search. |
submit_command |
Required. A command that submits individual runs to the
grid queue. The actual command submitted to the queue is constructed by
pyDarwin. It should not include |
submit_job_id_re |
Required. A regular expression pattern to extract the job ID after submission. The job ID must be captured with the first capturing group. |
poll_command |
Required. A command that retrieves finished jobs from the
grid controller. If the controller/setup allows to specify ids/patterns in
polling commands, do it. Otherwise, all finished jobs should be polled
using commands |
poll_job_id_re |
Required. A regular expression pattern to find a job ID in every line of the poll_command output. Similar to submit_job_id_re. |
poll_interval |
Optional. How often to poll jobs (in seconds). Default is 10 seconds. |
delete_command |
Optional. A command that deletes all unfinished jobs
related to the search when you stop it. It may delete all of them by ID
(e.g., |
A list containing the configured grid adapter options.
grid_options <- pyDarwinOptionsGridAdapter( python_path = "~/darwin/venv/bin/python", submit_search_command = "qsub -b y -cwd -o {project_stem}_out.txt -e {project_stem}_err.txt -N '{project_name}'", submit_command = "qsub -b y -o {results_dir}/{run_name}.out -e {results_dir}/{run_name}.err -N {job_name}", submit_job_id_re = "Your job (\\w+) \\(\".+?\"\\) has been submitted", poll_command = "qstat -s z", poll_job_id_re = "^\\s+(\\w+)", poll_interval = 10, delete_command = "qdel {project_stem}-*" )grid_options <- pyDarwinOptionsGridAdapter( python_path = "~/darwin/venv/bin/python", submit_search_command = "qsub -b y -cwd -o {project_stem}_out.txt -e {project_stem}_err.txt -N '{project_name}'", submit_command = "qsub -b y -o {results_dir}/{run_name}.out -e {results_dir}/{run_name}.err -N {job_name}", submit_job_id_re = "Your job (\\w+) \\(\".+?\"\\) has been submitted", poll_command = "qstat -s z", poll_job_id_re = "^\\s+(\\w+)", poll_interval = 10, delete_command = "qdel {project_stem}-*" )
Generates a list of specific options for the MOGA (Multi-Objective Genetic
Algorithm) or MOGA3 (NSGA-III) algorithms in pyDarwin. This list is
intended to be passed as the MOGA argument to the
create_pyDarwinOptions() function when algorithm is set to "MOGA" or
"MOGA3".
pyDarwinOptionsMOGA( objectives = 3, names = NULL, constraints = 0, partitions = 12, crossover = "single", crossover_rate = 0.95, mutation_rate = 0.95, attribute_mutation_probability = 0.1 )pyDarwinOptionsMOGA( objectives = 3, names = NULL, constraints = 0, partitions = 12, crossover = "single", crossover_rate = 0.95, mutation_rate = 0.95, attribute_mutation_probability = 0.1 )
objectives |
Positive integer: Number of objectives.
Applicable only when the |
names |
Character vector (optional): List of names for the objectives.
Applicable only when the |
constraints |
Non-negative integer: Number of constraints.
Applicable only when the |
partitions |
Positive integer: Number of partitions for the reference
directions used in NSGA-III.
Applicable only when the |
crossover |
Character string: Crossover algorithm. When set to "single", SinglePointCrossover is used. Otherwise, for other values like "two_point", TwoPointCrossover is typically used by pymoo. See https://pymoo.org/operators/crossover.html#Point-Crossover. Applicable for both "MOGA" and "MOGA3". Default: "single". |
crossover_rate |
Numeric value between 0.0 and 1.0: The fraction of mating pairs that will undergo crossover. Applicable for both "MOGA" and "MOGA3". Default: 0.95. |
mutation_rate |
Numeric value between 0.0 and 1.0: The probability that at least one bit in the genome will be "flipped" (mutated). Applicable for both "MOGA" and "MOGA3". Default: 0.95. |
attribute_mutation_probability |
Numeric value between 0.0 and 1.0: The probability of any individual bit (attribute) in the genome being mutated. Applicable for both "MOGA" and "MOGA3". Default: 0.1. |
This function defines parameters for the MOGA settings block in pyDarwin.
The relevance of certain parameters (objectives, names, constraints,
partitions) depends on whether the algorithm in
create_pyDarwinOptions() is set to "MOGA" (for NSGA-II) or "MOGA3"
(for NSGA-III).
If algorithm = "MOGA" (NSGA-II):
pyDarwin internally uses 2 objectives (OFV and NEP). The objectives,
names, constraints, and partitions parameters from this MOGA options
block are ignored by pyDarwin. Postprocessing scripts are not used by
pyDarwin to define objectives.
If algorithm = "MOGA3" (NSGA-III):
The objectives, names, constraints, and partitions parameters
from this MOGA options block are utilized by pyDarwin. User-supplied
postprocessing scripts (R or Python) are required to calculate and
return the values for the objectives and constraints.
(R: list of two vectors; Python: tuple of two lists).
Common parameters like crossover, crossover_rate, mutation_rate, and
attribute_mutation_probability apply to both "MOGA" and "MOGA3" variants.
A list containing MOGA-specific options.
# MOGA options, defaults are generally suitable for algorithm = "MOGA3" # if postprocessing handles 3 objectives. moga_block_for_moga3 <- pyDarwinOptionsMOGA( objectives = 3, names = c("Objective1", "Objective2", "Objective3"), constraints = 1, partitions = 10 ) # MOGA options where specific settings are for NSGA-II (algorithm = "MOGA") # Note: objectives, names, constraints, partitions would be ignored by pyDarwin. moga_block_for_moga <- pyDarwinOptionsMOGA( crossover = "two_point", crossover_rate = 0.92 )# MOGA options, defaults are generally suitable for algorithm = "MOGA3" # if postprocessing handles 3 objectives. moga_block_for_moga3 <- pyDarwinOptionsMOGA( objectives = 3, names = c("Objective1", "Objective2", "Objective3"), constraints = 1, partitions = 10 ) # MOGA options where specific settings are for NSGA-II (algorithm = "MOGA") # Note: objectives, names, constraints, partitions would be ignored by pyDarwin. moga_block_for_moga <- pyDarwinOptionsMOGA( crossover = "two_point", crossover_rate = 0.92 )
Generates a list of penalty parameters to be used in pyDarwin create_pyDarwinOptions function.
pyDarwinOptionsPenalty( theta = 10, omega = 10, sigma = 10, convergence = 100, covariance = 100, correlation = 100, condition_number = 100, non_influential_tokens = 1e-05 )pyDarwinOptionsPenalty( theta = 10, omega = 10, sigma = 10, convergence = 100, covariance = 100, correlation = 100, condition_number = 100, non_influential_tokens = 1e-05 )
theta |
numeric: Penalty added to fitness/reward for each estimated THETA. A value of 3.84 corresponds to a hypothesis test with 1 df and p < 0.05 (for nested models), and a value of 2 for 1 df corresponds to the Akaike information criterion. Default: 10 |
omega |
numeric: Penalty added to fitness/reward for each estimated OMEGA element. Default: 10 |
sigma |
numeric: Penalty added to fitness/reward for each estimated SIGMA element. Default: 10 |
convergence |
numeric: Penalty added to fitness/reward for failing to converge. Default: 100 |
covariance |
numeric: Penalty added to fitness/reward for failing the covariance step (real number). If a successful covariance step is important, this can be set to a large value (e.g., 100), otherwise, set to 0. Default: 100 |
correlation |
numeric: Penalty added to fitness/reward if any off-diagonal element of the correlation matrix of estimates has an absolute value > 0.95 (real number). This penalty will be added if the covariance step fails or is not requested. Default: 100 |
condition_number |
numeric: Penalty added if the covariance step fails or is not requested, e.g., PRINT=E is not included in $COV. Additionally, if the covariance is successful and the condition number of the covariance matrix is > 1000, then this penalty is added to the fitness/reward. Default: 100 |
non_influential_tokens |
numeric: Penalty added to fitness/reward if any tokens do not influence the control file (relevant for nested tokens). Should be very small (e.g., 0.0001), as the purpose is only for the model with non-influential tokens to be slightly worse than the same model without the non-influential token(s) to break a tie. Default: 0.00001 |
A list of penalty options in pyDarwin optimization process.
# Create penalty options with default values penalty_options <- pyDarwinOptionsPenalty() # Create penalty options with custom values penalty_options_custom <- pyDarwinOptionsPenalty(theta = 3.84, omega = 8, sigma = 6, convergence = 50, covariance = 80, correlation = 60, condition_number = 70, non_influential_tokens = 0.0001)# Create penalty options with default values penalty_options <- pyDarwinOptionsPenalty() # Create penalty options with custom values penalty_options_custom <- pyDarwinOptionsPenalty(theta = 3.84, omega = 8, sigma = 6, convergence = 50, covariance = 80, correlation = 60, condition_number = 70, non_influential_tokens = 0.0001)
Generates a list of postprocessing options to be used in pyDarwin optimization process.
pyDarwinOptionsPostprocess( use_r = FALSE, post_run_r_code = "{project_dir}/simplefunc.R", r_timeout = 30, use_python = FALSE, post_run_python_code = "{project_dir}/simplefunc.py" )pyDarwinOptionsPostprocess( use_r = FALSE, post_run_r_code = "{project_dir}/simplefunc.R", r_timeout = 30, use_python = FALSE, post_run_python_code = "{project_dir}/simplefunc.py" )
use_r |
Logical: Whether to use R for postprocessing. If set to TRUE, R
will be used to execute the post-processing script specified in
|
post_run_r_code |
Character: The file path to the R script that contains post-processing code. This script will be executed after the pyDarwin optimization process finishes. For NSGA-III (MOGA with 3 objectives), the R script must return a list containing two vectors: the first for objectives, the second for constraints (empty vector if no constraints). For other cases, it should return a vector containing a penalty value and a text string. Default: "{project_dir}/simplefunc.R". |
r_timeout |
Numeric: The time limit (in seconds) for the execution of the post-processing R script. If the R script takes longer to execute than this timeout value, it will be terminated. Default: 30. |
use_python |
Logical: Whether to use Python for postprocessing. If set
to TRUE, Python will be used to execute the post-processing script
specified in |
post_run_python_code |
Character: The file path to the Python script
that contains post-processing code.
The script must contain a function |
A list of postprocessing options in pyDarwin optimization process.
# Create postprocess options with default values postprocess_options <- pyDarwinOptionsPostprocess() # Create postprocess options with custom values postprocess_options_custom <- pyDarwinOptionsPostprocess(use_r = TRUE, post_run_r_code = "{project_dir}/postprocess.R", r_timeout = 60, use_python = TRUE, post_run_python_code = "{project_dir}/postprocess.py")# Create postprocess options with default values postprocess_options <- pyDarwinOptionsPostprocess() # Create postprocess options with custom values postprocess_options_custom <- pyDarwinOptionsPostprocess(use_r = TRUE, post_run_r_code = "{project_dir}/postprocess.R", r_timeout = 60, use_python = TRUE, post_run_python_code = "{project_dir}/postprocess.py")
This function allows you to set various options specific to the Particle Swarm Optimization (PSO) in pyDarwin.
pyDarwinOptionsPSO( inertia = 0.4, cognitive = 0.5, social = 0.5, neighbor_num = 20, p_norm = 2, break_on_no_change = 5 )pyDarwinOptionsPSO( inertia = 0.4, cognitive = 0.5, social = 0.5, neighbor_num = 20, p_norm = 2, break_on_no_change = 5 )
inertia |
A real value specifying the particle coordination movement as it relates to the previous velocity (commonly denoted as w). Default: 0.4 |
cognitive |
A real value specifying the particle coordination movement as it relates to its own best known position (commonly denoted as c1). Default: 0.5 |
social |
A real value specifying the particle coordination movement as it relates to the current best known position across all particles (commonly denoted as c2). Default: 0.5 |
neighbor_num |
A positive integer specifying the number of neighbors that any particle interacts with to determine the social component of the velocity of the next step. A smaller number of neighbors results in a more thorough search (as the neighborhoods tend to move more independently, allowing the swarm to cover a larger section of the total search space) but will converge more slowly. Default: 20 |
p_norm |
A positive integer specifying the Minkowski p-norm to use. A value of 1 is the sum-of-absolute values (or L1 distance) while 2 is the Euclidean (or L2) distance. Default: 2 |
break_on_no_change |
A positive integer specifying the number of iterations used to determine whether the optimization has converged. Default: 5 |
An object containing the specified options for the Particle Swarm Optimization (PSO) algorithm.
# Create PSO options with default values options <- pyDarwinOptionsPSO() # Create PSO options with custom values options <- pyDarwinOptionsPSO(inertia = 0.2, cognitive = 0.8, social = 0.7, neighbor_num = 10)# Create PSO options with default values options <- pyDarwinOptionsPSO() # Create PSO options with custom values options <- pyDarwinOptionsPSO(inertia = 0.2, cognitive = 0.8, social = 0.7, neighbor_num = 10)
This function reconnects to a pyDarwin job previously launched in the background on a remote host. It monitors the job until completion (if a PID is available), then downloads and processes the results.
reconnect_pyDarwinJob( LocalDirectoryPath = ".", LocalJobInfoFilePath = NULL, OriginalOptionsPath = NULL, Password = NULL, KeyPath = NULL, MonitoringInterval = 30, verbose = getOption("verbose", default = FALSE) )reconnect_pyDarwinJob( LocalDirectoryPath = ".", LocalJobInfoFilePath = NULL, OriginalOptionsPath = NULL, Password = NULL, KeyPath = NULL, MonitoringInterval = 30, verbose = getOption("verbose", default = FALSE) )
LocalDirectoryPath |
Character string: The base local directory associated
with the pyDarwin job. This directory is used to:
1. Locate the job information file (if |
LocalJobInfoFilePath |
Character string (optional): Explicit path to the local
JSON file containing information about the remote job (e.g., as created by
|
OriginalOptionsPath |
Character string (optional): Explicit path to the original
local |
Password |
Character string. The password for SSH authentication. Defaults
to |
KeyPath |
Character string. The path to your private SSH key file.
Defaults to the path stored in the |
MonitoringInterval |
Numeric. The interval in seconds between status
checks when monitoring a running job ( |
verbose |
Logical: Passed to helper functions for verbose output during
SSH connection and file downloads.
Default: |
This function requires a job information JSON file (typically created by
RunPyDarwinRemote when Wait = FALSE) to obtain details like the remote host,
user, remote project directory, and optionally the remote process ID (PID).
The ProjectName is crucial. It's primarily derived from the project_name
field in the original options file (located via OriginalOptionsPath or within
LocalDirectoryPath). If not present in the options file, a fallback derivation
uses the parent directory name of the options file. This ProjectName is then
used to find the job info file (as {ProjectName}_remote_job_info.json in
LocalDirectoryPath) if LocalJobInfoFilePath is not directly provided.
If the job info file itself contains a ProjectName, that value may take precedence.
Downloaded results are organized locally using this determined ProjectName.
If RemoteJobPID is available in the job info file, the function will actively
monitor the process. If the PID is not available, it will skip active monitoring
and proceed directly to attempt downloading any available results.
A list containing parsed results similar to RunPyDarwinRemote(Wait = TRUE)
(i.e., results data.frame, FinalResultFile, FinalControlFile,
DownloadedResultsDir, DownloadedItems), or the content of the
downloaded messages.txt as a character vector if primary result
files are not found or parsed successfully. If essential information
(like job info or options file) is missing, the function will stop.
run_pyDarwin(), run_pyDarwinRemote()
## Not run: # Assuming 'my_project_job_info.json' and 'options.json' exist in '~/darwin_runs/my_project_run' # and 'my_project_job_info.json' was created by a previous RunPyDarwinRemote(Wait=FALSE) call. # Example 1: Specifying only the local directory path # ProjectName will be derived from options.json within that path. # Job info file will be sought as {ProjectName}_remote_job_info.json. try({ reconnect_pyDarwinJob( LocalDirectoryPath = "~/darwin_runs/my_project_run" ) }) # Example 2: Specifying paths explicitly try({ reconnect_pyDarwinJob( LocalDirectoryPath = "~/darwin_runs/my_project_run", # Still used for downloads LocalJobInfoFilePath = "~/darwin_runs/my_project_run/my_project_remote_job_info.json", OriginalOptionsPath = "~/darwin_runs/my_project_run/options.json", KeyPath = "~/.ssh/id_rsa_remote_server" ) }) ## End(Not run)## Not run: # Assuming 'my_project_job_info.json' and 'options.json' exist in '~/darwin_runs/my_project_run' # and 'my_project_job_info.json' was created by a previous RunPyDarwinRemote(Wait=FALSE) call. # Example 1: Specifying only the local directory path # ProjectName will be derived from options.json within that path. # Job info file will be sought as {ProjectName}_remote_job_info.json. try({ reconnect_pyDarwinJob( LocalDirectoryPath = "~/darwin_runs/my_project_run" ) }) # Example 2: Specifying paths explicitly try({ reconnect_pyDarwinJob( LocalDirectoryPath = "~/darwin_runs/my_project_run", # Still used for downloads LocalJobInfoFilePath = "~/darwin_runs/my_project_run/my_project_remote_job_info.json", OriginalOptionsPath = "~/darwin_runs/my_project_run/options.json", KeyPath = "~/.ssh/id_rsa_remote_server" ) }) ## End(Not run)
Remove Covariate from PML models
remove_Covariate( PMLParametersSets, Name, StParmNames = NULL, PMLStructures = NULL )remove_Covariate( PMLParametersSets, Name, StParmNames = NULL, PMLStructures = NULL )
PMLParametersSets |
A list of PML parameters sets ( |
Name |
Character specifying the name of the covariate to be removed. |
StParmNames |
Character or character vector specifying names of
structural parameters from which the covariate will be removed. Can be set
to |
PMLStructures |
Character or character vector specifying names of PML
structures from which the covariate will be removed. For the naming
convention of PMLStructures, see Details section of see details section of
|
The current functionality does not support removing custom covariates that are defined within the PML code of custom model spaces.
An updated list of PML models (PMLModels class instance) matching
the specified options.
Functions used for Covariate specification:
Covariate(),
add_Covariate(),
create_ModelPD(),
create_ModelPK()
PMLParametersSets <- get_PMLParametersSets() PMLParametersSetsWT <- add_Covariate(PMLParametersSets, Name = "WT", Type = "Continuous", State = "Present", Direction = "Forward", Center = 70) PMLParametersSetsVonly <- remove_Covariate(PMLParametersSets = PMLParametersSetsWT, Name = "WT", StParmNames = "Cl")PMLParametersSets <- get_PMLParametersSets() PMLParametersSetsWT <- add_Covariate(PMLParametersSets, Name = "WT", Type = "Continuous", State = "Present", Direction = "Forward", Center = 70) PMLParametersSetsVonly <- remove_Covariate(PMLParametersSets = PMLParametersSetsWT, Name = "WT", StParmNames = "Cl")
Remove Observation from PML models
remove_Observation(PMLParametersSets, ObservationName, PMLStructures = NULL)remove_Observation(PMLParametersSets, ObservationName, PMLStructures = NULL)
PMLParametersSets |
A list of PML parameters sets ( |
ObservationName |
A character string giving the name of the Observation. |
PMLStructures |
Character or character vector specifying names of PML
structures from which the observation will be removed. For the naming
convention of PMLStructures, see Details section of
|
The current functionality does not support modifying custom observations that are defined within the PML code of custom model spaces.
An updated list of PML models (PMLModels class instance) matching
the specified options.
Functions used for Observation specification:
Observation(),
ObservationCustom(),
Sigmas(),
create_ModelPD(),
create_ModelPK(),
modify_Observation()
PMLParametersSets <- create_ModelPK( CompartmentsNumber = c(2, 3), Parameterization = "Micro", Absorption = c("First-Order", "Gamma"), ByVector = TRUE, ClosedForm = TRUE, EliminationCpt = TRUE) remove_Observation(PMLParametersSets, ObservationName = "A0Obs", PMLStructures = "PK3GME")PMLParametersSets <- create_ModelPK( CompartmentsNumber = c(2, 3), Parameterization = "Micro", Absorption = c("First-Order", "Gamma"), ByVector = TRUE, ClosedForm = TRUE, EliminationCpt = TRUE) remove_Observation(PMLParametersSets, ObservationName = "A0Obs", PMLStructures = "PK3GME")
Remove structural parameter from PML models
remove_StParm(PMLParametersSets, StParmName, PMLStructures = NULL)remove_StParm(PMLParametersSets, StParmName, PMLStructures = NULL)
PMLParametersSets |
A list of PML parameters sets ( |
StParmName |
character specifying the name for the structural parameter to be removed. |
PMLStructures |
Character or character vector specifying names of PML
structures from which the structural parameter will be removed. For the
naming convention of PMLStructures, see Details section of
|
Please make sure that structural parameter to be removed is not
essential for the model. Usually the user does not need to remove
any structural parameter. The only case is related to structural parameters
in Dosepoint().
An updated list of PML models (PMLModels class instance) matching
the specified options.
Functions used for StParm specification:
StParm(),
add_StParm(),
create_ModelPD(),
create_ModelPK(),
modify_StParm(),
modify_StParmCustom()
PMLParametersSets <- get_PMLParametersSets(CompartmentsNumber = c(1, 2)) PMLParametersSetsDuration <- add_StParm(PMLParametersSets, StParmName = "Duration", State = "Searched", DosepointArgName = "duration") PMLParametersSetsDuration1CptOnly <- remove_StParm(PMLParametersSetsDuration, StParmName = "Duration", PMLStructures = "PK2IVC")PMLParametersSets <- get_PMLParametersSets(CompartmentsNumber = c(1, 2)) PMLParametersSetsDuration <- add_StParm(PMLParametersSets, StParmName = "Duration", State = "Searched", DosepointArgName = "duration") PMLParametersSetsDuration1CptOnly <- remove_StParm(PMLParametersSetsDuration, StParmName = "Duration", PMLStructures = "PK2IVC")
This function executes a pyDarwin model search by calling the specified Python
interpreter and the darwin.run_search module.
run_pyDarwin( InterpreterPath, Flags = c("-u", "-m"), DirectoryPath = ".", TemplatePath = "template.txt", TokensPath = "tokens.json", OptionsPath = "options.json", Wait = TRUE )run_pyDarwin( InterpreterPath, Flags = c("-u", "-m"), DirectoryPath = ".", TemplatePath = "template.txt", TokensPath = "tokens.json", OptionsPath = "options.json", Wait = TRUE )
InterpreterPath |
Character string. The full path to the Python
interpreter executable (e.g., |
Flags |
Character vector. Optional flags passed directly to the Python
interpreter. Defaults to |
DirectoryPath |
Character string. Optional path to the directory
containing the |
TemplatePath |
Character string. Path to the pyDarwin template file
(typically |
TokensPath |
Character string. Path to the pyDarwin tokens JSON file
(typically |
OptionsPath |
Character string. Path to the pyDarwin options JSON file
(typically |
Wait |
Logical. If |
If Wait = TRUE: A list containing the search results read from the
output_dir (specified in options.json). This typically includes:
results: A data frame (results.csv).
FinalResultFile: Character vector containing lines from the
final model's result file (e.g., .lst, .txt).
FinalControlFile: Character vector containing lines from the
final model's control file (e.g., .mod, .mmdl).
If result files are not found, warnings are issued. If no results are
found but messages.txt exists, its content might be returned with a
warning. If the Python call fails (non-zero exit code), the function stops
with an error.
If Wait = FALSE: A character string giving the full path to the main
pyDarwin log file (messages.txt) within the working_dir.
Wait = FALSE)When Wait is set to FALSE, the pyDarwin process is launched in the
background, and the R function returns immediately. This allows R to continue
processing while pyDarwin runs.
Output Redirection: Standard output (stdout) and standard error
(stderr) from the Python process are redirected to files named
stdout.log and stderr.log respectively, within the working_dir.
These files are crucial for diagnosing issues if the background process
fails or behaves unexpectedly.
Primary Log: The main pyDarwin log file (messages.txt, located
in the working_dir) remains the primary source for detailed run
information, but the stdout.log and stderr.log capture console
output and errors directly.
run_pyDarwinRemote(), reconnect_pyDarwinJob()
## Not run: # Example: Running pyDarwin and waiting for results # Assuming python is in the PATH and input files are in 'my_project' results <- run_pyDarwin( InterpreterPath = "python", DirectoryPath = "my_project", Wait = TRUE ) print(results$results) # Example: Launching pyDarwin in the background log_file_path <- run_pyDarwin( InterpreterPath = "python", DirectoryPath = "my_project", Wait = FALSE ) ## End(Not run)## Not run: # Example: Running pyDarwin and waiting for results # Assuming python is in the PATH and input files are in 'my_project' results <- run_pyDarwin( InterpreterPath = "python", DirectoryPath = "my_project", Wait = TRUE ) print(results$results) # Example: Launching pyDarwin in the background log_file_path <- run_pyDarwin( InterpreterPath = "python", DirectoryPath = "my_project", Wait = FALSE ) ## End(Not run)
Establishes an SSH connection, prepares and uploads project files, executes pyDarwin in the background, and can optionally monitor the job and download results upon completion.
run_pyDarwinRemote( Host, User, Password = "", KeyPath = Sys.getenv("SSH_PRIVATE_KEY_PATH"), SshFlags = character(0), LocalTemplatePath, LocalTokensPath, LocalOptionsPath, LocalDirectoryPath = ".", RemoteBaseDir = "~/.rdarwin/", RemoteInterpreterPath = NULL, UseLocalLicense = FALSE, Wait = TRUE, Flags = c("-u", "-m"), MonitoringInterval = 30 )run_pyDarwinRemote( Host, User, Password = "", KeyPath = Sys.getenv("SSH_PRIVATE_KEY_PATH"), SshFlags = character(0), LocalTemplatePath, LocalTokensPath, LocalOptionsPath, LocalDirectoryPath = ".", RemoteBaseDir = "~/.rdarwin/", RemoteInterpreterPath = NULL, UseLocalLicense = FALSE, Wait = TRUE, Flags = c("-u", "-m"), MonitoringInterval = 30 )
Host |
Character string. The hostname or IP address of the remote server. |
User |
Character string. The username for the SSH connection. |
Password |
Character string. The password for SSH authentication. Defaults
to |
KeyPath |
Character string. The path to your private SSH key file.
Defaults to the path stored in the |
SshFlags |
Character vector. Additional flags to pass to the underlying
|
LocalTemplatePath |
Character string. The path to the pyDarwin template
file. If not provided, defaults to |
LocalTokensPath |
Character string. The path to the pyDarwin tokens JSON
file. If not provided, defaults to |
LocalOptionsPath |
Character string. The path to the pyDarwin options
JSON file. If not provided, defaults to |
LocalDirectoryPath |
Character string or |
RemoteBaseDir |
Character string. The base directory on the remote host under which a new project-specific directory will be created. |
RemoteInterpreterPath |
Character string or |
UseLocalLicense |
Logical. If |
Wait |
Logical. If |
Flags |
Character vector. Command-line flags to pass to the |
MonitoringInterval |
Numeric. The interval in seconds between status
checks when monitoring a running job ( |
This function automates the entire remote execution workflow. It creates a unique project directory on the remote host to ensure run isolation.
The return value depends on the Wait parameter:
If Wait = TRUE |
On successful completion, a list containing the
parsed results, similar to |
If Wait = FALSE |
An invisible list containing information needed to
reconnect to the job later using
|
The function throws an error if a critical step fails.
create_pyDarwinOptions(), reconnect_pyDarwinJob()
## Not run: # Example of launching a remote job and waiting for the results remote_results <- run_pyDarwinRemote( Host = "cluster.mycompany.com", User = "myuser", KeyPath = "~/.ssh/id_rsa_cluster", LocalDirectoryPath = "path/to/my/CovariateSearchProject" ) # Example of launching a job in the background job_info <- run_pyDarwinRemote( Host = "cluster.mycompany.com", User = "myuser", KeyPath = "~/.ssh/id_rsa_cluster", LocalDirectoryPath = "path/to/my/CovariateSearchProject", Wait = FALSE ) # You can later use job_info to reconnect to the job # final_results <- reconnect_pyDarwinJob(JobInfo = job_info) ## End(Not run)## Not run: # Example of launching a remote job and waiting for the results remote_results <- run_pyDarwinRemote( Host = "cluster.mycompany.com", User = "myuser", KeyPath = "~/.ssh/id_rsa_cluster", LocalDirectoryPath = "path/to/my/CovariateSearchProject" ) # Example of launching a job in the background job_info <- run_pyDarwinRemote( Host = "cluster.mycompany.com", User = "myuser", KeyPath = "~/.ssh/id_rsa_cluster", LocalDirectoryPath = "path/to/my/CovariateSearchProject", Wait = FALSE ) # You can later use job_info to reconnect to the job # final_results <- reconnect_pyDarwinJob(JobInfo = job_info) ## End(Not run)
This function creates a new instance of different error models object to be applied. 0s are treated as no values.
Sigmas( Additive = 0, LogAdditive = 0, Proportional = 0.1, AdditiveMultiplicative = list(PropPart = 0, AddPart = 0), MixRatio = list(PropPart = 0, AddPart = 0), Power = list(PowerPart = 0, StdevPart = 0), ObservationName = "" )Sigmas( Additive = 0, LogAdditive = 0, Proportional = 0.1, AdditiveMultiplicative = list(PropPart = 0, AddPart = 0), MixRatio = list(PropPart = 0, AddPart = 0), Power = list(PowerPart = 0, StdevPart = 0), ObservationName = "" )
Additive |
The additive error sigma value. |
LogAdditive |
The log-additive error sigma value. |
Proportional |
The proportional error sigma value. |
AdditiveMultiplicative |
A list specifying the additive and
multiplicative parts for the additive-multiplicative error model. The list
should have elements |
MixRatio |
A list specifying the proportional and additive parts for the
mix-ratio error model. The list should have elements |
Power |
A numeric vector specifying the standard deviation and power
parts for the power error model. The vector should have names |
ObservationName |
A character string giving the name of the Observation. |
A Sigmas class instance.
Functions used for Observation specification:
Observation(),
ObservationCustom(),
create_ModelPD(),
create_ModelPK(),
modify_Observation(),
remove_Observation()
RSE_CObs <- Observation(SigmasChosen = Sigmas(MixRatio = list(PropPart = 2, AddPart = 0.01), Proportional = 0)) models <- create_ModelPK(CompartmentsNumber = 2, CObs = RSE_CObs) print(models)RSE_CObs <- Observation(SigmasChosen = Sigmas(MixRatio = list(PropPart = 2, AddPart = 0.01), Proportional = 0)) models <- create_ModelPK(CompartmentsNumber = 2, CObs = RSE_CObs) print(models)
Defines optional engine parameters to control the estimation or simulation
process in Phoenix NLME. This function generates a single character
string containing space-separated name=value pairs for non-default
settings. Parameters are included in the output string according to the order
in the function signature.
specify_EngineParams( sort = FALSE, ODE = c("MatrixExponent", "DVERK", "DOPRI5", "AutoDetect", "Stiff", "LSODE"), rtolODE = 1e-06, atolODE = 1e-06, maxStepsODE = 50000L, numIterations = 1000L, method = c("FOCE-ELS", "QRPEM", "Laplacian", "Naive-Pooled", "FOCE-LB", "IT2S-EM", "FO"), stdErr = c("Sandwich", "Hessian", "Fisher-Score", "Auto-Detect", "None"), isCentralDiffStdErr = TRUE, stepSizeStdErr = 0.01, logTransform = NULL, numIntegratePtsAGQ = 1L, numIterNonParametric = 0L, fastOptimization = FALSE, numIterMAPNP = 0L, numRepPCWRES = 0L, stepSizeLinearize = 0.002, numDigitLaplacian = 7L, numDigitBlup = 13L, gradTolOuter = 2e-04, stepTolOuter = 1e-04, gradTolInner = 1.71e-05, stepTolInner = 7.07e-08, refDeltaLagl = 0.001, mapAssist = 0L, iSample = 300L, iAcceptRatio = 0.1, impDist = c("Normal", "DoubleExponential", "Direct", "T", "Mixture-2", "Mixture-3"), tDOF = 4L, numSampleSIR = 10L, numBurnIn = 0L, freezeOmega = FALSE, MCPEM = FALSE, runAllIterations = FALSE, scramble = c("Owen", "Tezuka-Faur", "None"), emTolType = 0L, emConvLen = 10L, emConvCritVal = 5, stepSizePartialDeriv = 1e-05, numTimeStepPartialDeriv = 20L )specify_EngineParams( sort = FALSE, ODE = c("MatrixExponent", "DVERK", "DOPRI5", "AutoDetect", "Stiff", "LSODE"), rtolODE = 1e-06, atolODE = 1e-06, maxStepsODE = 50000L, numIterations = 1000L, method = c("FOCE-ELS", "QRPEM", "Laplacian", "Naive-Pooled", "FOCE-LB", "IT2S-EM", "FO"), stdErr = c("Sandwich", "Hessian", "Fisher-Score", "Auto-Detect", "None"), isCentralDiffStdErr = TRUE, stepSizeStdErr = 0.01, logTransform = NULL, numIntegratePtsAGQ = 1L, numIterNonParametric = 0L, fastOptimization = FALSE, numIterMAPNP = 0L, numRepPCWRES = 0L, stepSizeLinearize = 0.002, numDigitLaplacian = 7L, numDigitBlup = 13L, gradTolOuter = 2e-04, stepTolOuter = 1e-04, gradTolInner = 1.71e-05, stepTolInner = 7.07e-08, refDeltaLagl = 0.001, mapAssist = 0L, iSample = 300L, iAcceptRatio = 0.1, impDist = c("Normal", "DoubleExponential", "Direct", "T", "Mixture-2", "Mixture-3"), tDOF = 4L, numSampleSIR = 10L, numBurnIn = 0L, freezeOmega = FALSE, MCPEM = FALSE, runAllIterations = FALSE, scramble = c("Owen", "Tezuka-Faur", "None"), emTolType = 0L, emConvLen = 10L, emConvCritVal = 5, stepSizePartialDeriv = 1e-05, numTimeStepPartialDeriv = 20L )
sort |
Logical; Specifies whether to sort the input data by subject and
time. Default: |
ODE |
Character; Specifies the ODE solver. Options: |
rtolODE |
Numeric; Relative tolerance for the ODE solver.
Default: |
atolODE |
Numeric; Absolute tolerance for the ODE solver.
Default: |
maxStepsODE |
Integer; Maximum number of steps for the ODE solver.
Default: |
numIterations |
Integer; Maximum number of estimation iterations (max:
10000).
Default: |
method |
Character; Estimation method. Options: |
stdErr |
Character; Standard error computation method. Options:
|
isCentralDiffStdErr |
Logical; Use central ( |
stepSizeStdErr |
Numeric; Relative step size for numerical Hessian
computation for standard errors. Must be positive. Default: |
logTransform |
Logical or NULL; Controls log-transformation behavior for
models with log-additive residual error (e.g., C*exp(epsilon)).
Default:
Note: This function includes |
numIntegratePtsAGQ |
Integer; Number of quadrature points per dimension
for Adaptive Gaussian Quadrature (AGQ). 1 means no AGQ. >1 enables AGQ.
Default: |
numIterNonParametric |
Integer; Controls non-parametric (NP)
optimization. 0: Disable. 1: NONMEM-style NP. >1: Evolutionary NP algorithm
generations.
Default: |
fastOptimization |
Logical; Use Automatic Differentiation ( |
numIterMAPNP |
Integer; Number of preliminary Naive-Pooled iterations.
Default: |
numRepPCWRES |
Integer; Replicates for PCWRES (max 10000). 0 disables
calculation.
Default: |
stepSizeLinearize |
Numeric; Relative step size for numerical
differentiation during linearization. Must be positive. Default:
|
numDigitLaplacian |
Integer; Optimization accuracy (NDIGIT) for the
outer loop ( |
numDigitBlup |
Integer; Optimization accuracy (NDIGIT) for the inner
loop (etas) or for |
gradTolOuter |
Numeric; Max gradient tolerance, outer loop.
Non-negative.
Default: |
stepTolOuter |
Numeric; Max step tolerance, outer loop. Non-negative.
Default: |
gradTolInner |
Numeric; Max gradient tolerance, inner loop (etas).
Non-negative.
Default: |
stepTolInner |
Numeric; Max step tolerance, inner loop (etas).
Non-negative.
Default: |
refDeltaLagl |
Numeric; Log-likelihood change tolerance. Non-negative.
Default: |
mapAssist |
Integer; Periodicity for MAP assistance. 0 disables.
Default: |
iSample |
Integer; Sample points. Positive integer.
Default: |
iAcceptRatio |
Numeric; Acceptance ratio for covariance scaling.
Positive.
Default: |
impDist |
Character; Importance sampling distribution. Options:
|
tDOF |
Integer; Degrees of freedom for T distribution importance
sampling (3-30).
Default: |
numSampleSIR |
Integer; Samples per eta per subject for SIR. Positive
integer.
Default: |
numBurnIn |
Integer; Burn-in iterations.
Default: |
freezeOmega |
Logical; Freeze Omega during burn-in.
Default: |
MCPEM |
Logical; Use Monte-Carlo ( |
runAllIterations |
Logical; Force execution of all iterations.
Default: |
scramble |
Character; Quasi-random scrambling. Options: |
emTolType |
Integer; QRPEM convergence check type (0-3).
Default: |
emConvLen |
Integer; Iterations for QRPEM convergence check window.
Positive.
Default: |
emConvCritVal |
Numeric; Critical value for QRPEM convergence check.
Positive.
Default: |
stepSizePartialDeriv |
Numeric; Step size for numerical partial
derivatives. Positive.
Default: |
numTimeStepPartialDeriv |
Integer; Time steps for outputting partial
derivatives. Positive integer.
Default: |
This function allows customization of the NLME engine settings.
Parameters are validated based on type, range, and applicability (detailed in
parameter descriptions). Only parameters explicitly set to a value different
from their default for the specified context (e.g., method-specific
defaults for stdErr) are included in the output string. Values are returned
as character strings.
Important Note on Defaults: Uses fixed defaults as specified in the argument
list for comparison unless otherwise noted (e.g., stdErr). The actual
default applied by NLME might differ based on model context (population vs
individual, presence of reset info, discontinuities, BQL data).
Parameter Applicability & Warnings:
The function checks for common cases where provided parameters might be
ignored by the NLME engine based on the selected method or other settings.
Warnings are issued in such cases. It assumes population context unless
method="Naive-Pooled".
A single character string containing space-separated name=value
pairs, ordered according to the function signature. Includes parameters if
specified with non-default values (using method-specific defaults for
stdErr).
write_ModelTemplateTokens(), specify_SimParams()
# Default settings EstArgs_def <- specify_EngineParams() print(EstArgs_def) # Setting sort = TRUE EstArgs_sort_true <- specify_EngineParams(sort = TRUE) print(EstArgs_sort_true) # QRPEM method with several custom settings EstArgs_qrpem_str <- specify_EngineParams( sort = TRUE, # Explicitly non-default ODE = "DVERK", rtolODE = 1e-5, numIterations = 500, method = "QRPEM", isCentralDiffStdErr = FALSE, numIterMAPNP = 3, iSample = 350, impDist = "Mixture-2", scramble = "Tezuka-Faur", numBurnIn = 10, freezeOmega = TRUE ) print(EstArgs_qrpem_str)# Default settings EstArgs_def <- specify_EngineParams() print(EstArgs_def) # Setting sort = TRUE EstArgs_sort_true <- specify_EngineParams(sort = TRUE) print(EstArgs_sort_true) # QRPEM method with several custom settings EstArgs_qrpem_str <- specify_EngineParams( sort = TRUE, # Explicitly non-default ODE = "DVERK", rtolODE = 1e-5, numIterations = 500, method = "QRPEM", isCentralDiffStdErr = FALSE, numIterMAPNP = 3, iSample = 350, impDist = "Mixture-2", scramble = "Tezuka-Faur", numBurnIn = 10, freezeOmega = TRUE ) print(EstArgs_qrpem_str)
Use to define engine parameters for model simulation. Generates a single
character string containing space-separated name=value pairs.
specify_SimParams( numReplicates = 100L, seed = 1234L, sort = FALSE, ODE = c("MatrixExponent", "DVERK", "DOPRI5", "AutoDetect", "Stiff"), rtolODE = 1e-06, atolODE = 1e-06, maxStepsODE = 50000L )specify_SimParams( numReplicates = 100L, seed = 1234L, sort = FALSE, ODE = c("MatrixExponent", "DVERK", "DOPRI5", "AutoDetect", "Stiff"), rtolODE = 1e-06, atolODE = 1e-06, maxStepsODE = 50000L )
numReplicates |
Integer; Number of replicates (simulations) to generate. Must be positive. Always included in output. |
seed |
Integer; Seed for the random number generator used during simulation. Always included in output. |
sort |
Logical; Specifies whether to sort the input data by subject and
time before simulation. Default: |
ODE |
Character; Specifies the ODE solver. Options: |
rtolODE |
Numeric; Relative tolerance for the ODE solver.
Default: |
atolODE |
Numeric; Absolute tolerance for the ODE solver.
Default: |
maxStepsODE |
Integer; Maximum number of steps for the ODE solver.
Default: |
This function allows customization of the NLME engine settings specific to simulation runs. Parameters are validated based on type and range.
The parameters numReplicates, seed, and sort are always included in
the output string. Other parameters (ODE, rtolODE, atolODE,
maxStepsODE) are included only if their specified value differs from the
function's default value and they are applicable (ODE tolerances are
ignored if ODE="MatrixExponent").
Values are returned as character strings. The order of parameters in the output string matches the order in the function definition.
A single character string containing space-separated name=value
pairs, ordered according to the function signature. Includes
numReplicates, seed, sort always, and other parameters if specified
with non-default, applicable values.
write_ModelTemplateTokens(), specify_EngineParams(), Table()
# Default settings (includes numReplicates, seed, sort) SimArgs1 <- specify_SimParams() print(SimArgs1) # Custom settings SimArgs2 <- specify_SimParams( numReplicates = 50, seed = 9876, sort = TRUE, # Non-default ODE = "DVERK", # Non-default rtolODE = 1e-5 # Non-default and applicable ) print(SimArgs2) # Custom settings where ODE tolerances are ignored SimArgs3 <- specify_SimParams( numReplicates = 20, ODE = "MatrixExponent", # Default, but tolerances are now inapplicable rtolODE = 1e-4 # Non-default, but ignored ) print(SimArgs3)# Default settings (includes numReplicates, seed, sort) SimArgs1 <- specify_SimParams() print(SimArgs1) # Custom settings SimArgs2 <- specify_SimParams( numReplicates = 50, seed = 9876, sort = TRUE, # Non-default ODE = "DVERK", # Non-default rtolODE = 1e-5 # Non-default and applicable ) print(SimArgs2) # Custom settings where ODE tolerances are ignored SimArgs3 <- specify_SimParams( numReplicates = 20, ODE = "MatrixExponent", # Default, but tolerances are now inapplicable rtolODE = 1e-4 # Non-default, but ignored ) print(SimArgs3)
This function stops a pyDarwin model search.
stop_pyDarwin( InterpreterPath, Flags = c("-u", "-m"), ForceStop = FALSE, DirectoryPath = "." )stop_pyDarwin( InterpreterPath, Flags = c("-u", "-m"), ForceStop = FALSE, DirectoryPath = "." )
InterpreterPath |
Path to the Python interpreter executable. |
Flags |
Flags to pass to the Python interpreter. Refer to Python
documentation for details. Note that |
ForceStop |
Logical. If |
DirectoryPath |
the |
Returned code of system2() call.
## Not run: stop_pyDarwin( InterpreterPath = "~/darwin/venv/bin/python", DirectoryPath = "~/project_folder") ## End(Not run)## Not run: stop_pyDarwin( InterpreterPath = "~/darwin/venv/bin/python", DirectoryPath = "~/project_folder") ## End(Not run)
Attempts to gracefully stop a running pyDarwin job on a remote host by creating a 'stop.darwin' file in the remote project directory.
stop_pyDarwinRemote( LocalDirectoryPath, LocalJobInfoFilePath = NULL, OriginalOptionsPath = NULL, Password = NULL, KeyPath = NULL, verbose = getOption("verbose", default = FALSE) )stop_pyDarwinRemote( LocalDirectoryPath, LocalJobInfoFilePath = NULL, OriginalOptionsPath = NULL, Password = NULL, KeyPath = NULL, verbose = getOption("verbose", default = FALSE) )
LocalDirectoryPath |
Character string: The base local directory associated with the pyDarwin job. This directory is used to locate the job information file and the original options file. |
LocalJobInfoFilePath |
Character string (optional): Explicit path to the local
JSON file containing remote job information. If NULL (default), it's
constructed using |
OriginalOptionsPath |
Character string (optional): Explicit path to the original
local |
Password |
Character string. The password for SSH authentication. Defaults
to |
KeyPath |
Character string. The path to your private SSH key file.
Defaults to the path stored in the |
verbose |
Logical: Passed to |
Invisibly returns TRUE if the stop signal file was successfully created
(or already existed), and FALSE if there was an SSH error or an error
creating the file. This only signals the intent to stop; it does not
confirm the pyDarwin process has actually stopped.
## Not run: # Assuming 'my_project_remote_job_info.json' and 'options.json' # exist in '~/darwin_runs/my_project_run'. try({ stop_pyDarwinRemote( LocalDirectoryPath = "~/darwin_runs/my_project_run", KeyPath = "~/.ssh/id_rsa_remote" ) }) # Explicitly providing paths try({ stop_pyDarwinRemote( LocalDirectoryPath = "~/darwin_runs/my_project_run", # Still used as a base if needed LocalJobInfoFilePath = "~/darwin_runs/my_project_run/my_project_remote_job_info.json", OriginalOptionsPath = "~/darwin_runs/my_project_run/options.json" ) }) ## End(Not run)## Not run: # Assuming 'my_project_remote_job_info.json' and 'options.json' # exist in '~/darwin_runs/my_project_run'. try({ stop_pyDarwinRemote( LocalDirectoryPath = "~/darwin_runs/my_project_run", KeyPath = "~/.ssh/id_rsa_remote" ) }) # Explicitly providing paths try({ stop_pyDarwinRemote( LocalDirectoryPath = "~/darwin_runs/my_project_run", # Still used as a base if needed LocalJobInfoFilePath = "~/darwin_runs/my_project_run/my_project_remote_job_info.json", OriginalOptionsPath = "~/darwin_runs/my_project_run/options.json" ) }) ## End(Not run)
This function creates a new instance of a Structural parameter.
StParm( StParmName = character(), Type = "LogNormal", State = "Present", ThetaStParm = list(), OmegaStParm = list(), Covariates = list(), PMLStructure = character() )StParm( StParmName = character(), Type = "LogNormal", State = "Present", ThetaStParm = list(), OmegaStParm = list(), Covariates = list(), PMLStructure = character() )
StParmName |
Character specifying the name of the structural parameter. |
Type |
Character specifying the type of the structural parameter. Options are
|
State |
character string that indicates the presence of the structural parameter. Options are:
|
ThetaStParm |
A Theta class instance inside the structural parameter. If
not given, the associated Theta will be automatically created with its name
set to "tv" + |
OmegaStParm |
An Omega class instance inside the structural parameter.
If not given, the associated Omega will be automatically created with its
name set to "n" + |
Covariates |
A list of covariates ( |
PMLStructure |
Character specifying the name of PML
structure for which current parameter should be attributed. For the
naming convention of PMLStructures, see Details section of
|
An instance of a structural parameter.
Functions used for StParm specification:
add_StParm(),
create_ModelPD(),
create_ModelPK(),
modify_StParm(),
modify_StParmCustom(),
remove_StParm()
# Create a Structural parameter instance with default values V <- StParm(StParmName = "V") # Create a Structural parameter with Normal type: V2 <- StParm("V2", Type = "Normal", ThetaStParm = Theta(Name = "tvV2", InitialEstimates = 0.1)) # Create a Structural parameter instance with covariates: Cl <- StParm( StParmName = "Cl", Covariates = Covariate( Name = "Period", Type = "Occasion", State = "Searched", Categories = c(1,2), Omegas = list(Omega(Name = "nPeriodx1", 2), Omega(Name = "nPeriodx2", 3))), PMLStructure = "1CFOE")# Create a Structural parameter instance with default values V <- StParm(StParmName = "V") # Create a Structural parameter with Normal type: V2 <- StParm("V2", Type = "Normal", ThetaStParm = Theta(Name = "tvV2", InitialEstimates = 0.1)) # Create a Structural parameter instance with covariates: Cl <- StParm( StParmName = "Cl", Covariates = Covariate( Name = "Period", Type = "Occasion", State = "Searched", Categories = c(1,2), Omegas = list(Omega(Name = "nPeriodx1", 2), Omega(Name = "nPeriodx2", 3))), PMLStructure = "1CFOE")
Creates Table class object used to specify triggers and columns for tables output.
Table( Name = "table01.csv", TimesList = numeric(0), CovrSet = "", WhenDose = "", WhenObs = "", VariablesList = "", KeepSource = FALSE, TimeAfterDose = FALSE, IRES = FALSE, Weight = FALSE, IWRES = FALSE, Mode = "all", ForSimulation = FALSE )Table( Name = "table01.csv", TimesList = numeric(0), CovrSet = "", WhenDose = "", WhenObs = "", VariablesList = "", KeepSource = FALSE, TimeAfterDose = FALSE, IRES = FALSE, Weight = FALSE, IWRES = FALSE, Mode = "all", ForSimulation = FALSE )
Name |
Character; Name of the generated table. |
TimesList |
Numeric; Time values for simulation. Applicable for
time-based models only. Ignored when |
CovrSet |
Character; Vector of covariate names. Simulation point is added when the covariate value is set. |
WhenDose |
Character or logical;
Vector of dosing compartment names. Alternatively if |
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 |
TimeAfterDose |
Set to |
IRES |
Logical; Set to |
Weight |
Logical; Set to |
IWRES |
Logical; Set to |
Mode |
Character; The mode of output. Options are |
ForSimulation |
Logical; Set to |
If the table has a flag ForSimulation==TRUE, it will be ignored
and won't be generated during estimation stage. Simulation stage should be
added for simulation table generation. Tables with ForSimulation==FALSE
will be ignored during simulation stage.
A Table class used to store custom table information.
table01 <- Table(Name = "table01.csv", TimesList = seq(1,3,1), CovrSet = "WT", WhenDose = "A1", WhenObs = "CObs", VariablesList = "C", KeepSource = FALSE, TimeAfterDose = TRUE, IRES = TRUE, Weight = TRUE, IWRES = TRUE, ForSimulation = FALSE)table01 <- Table(Name = "table01.csv", TimesList = seq(1,3,1), CovrSet = "WT", WhenDose = "A1", WhenObs = "CObs", VariablesList = "C", KeepSource = FALSE, TimeAfterDose = TRUE, IRES = TRUE, Weight = TRUE, IWRES = TRUE, ForSimulation = FALSE)
Create a new Theta instance with validation.
Theta( Name = character(), InitialEstimates = 1, State = "Present", Frozen = FALSE, StParmName = character(), PMLStructure = character() )Theta( Name = character(), InitialEstimates = 1, State = "Present", Frozen = FALSE, StParmName = character(), PMLStructure = character() )
Name |
A character string representing the name of the Theta instance. |
InitialEstimates |
An |
State |
Character specifying the presence of the Theta. Possible values are:
|
Frozen |
A logical value indicating whether the Theta will be estimated or not. |
StParmName |
A character specifying the corresponding structural
parameter name. Used for the |
PMLStructure |
PML structure current theta belongs to |
A Theta instance.
Functions used for Theta specification:
InitialEstimate(),
create_ModelPD(),
create_ModelPK(),
modify_Theta()
# Create a new Theta instance with a name 'tvV' and initial value 2 (no bounds) theta <- Theta(Name = "tvV", InitialEstimates = 2)# Create a new Theta instance with a name 'tvV' and initial value 2 (no bounds) theta <- Theta(Name = "tvV", InitialEstimates = 2)
This function generates and writes the model template and tokens files based on the provided inputs.
write_ModelTemplateTokens( TemplateFilePath = "template.txt", TokensFilePath = "tokens.json", Description = "", Author = "", DataFilePath, DataMapping = NULL, ColDef = "", PMLParametersSets, EstArgs = specify_EngineParams(), SimArgs = "", Tables = list(), AppendixRows = "", OmegaSearchBlocks = list() )write_ModelTemplateTokens( TemplateFilePath = "template.txt", TokensFilePath = "tokens.json", Description = "", Author = "", DataFilePath, DataMapping = NULL, ColDef = "", PMLParametersSets, EstArgs = specify_EngineParams(), SimArgs = "", Tables = list(), AppendixRows = "", OmegaSearchBlocks = list() )
TemplateFilePath |
TemplateFilePath NLME template file path to be written (usually txt). |
TokensFilePath |
json file path to be written (usually json). |
Description |
A problem name to be outputted in Description section. |
Author |
The author information for the model to be outputted in Author section. |
DataFilePath |
A data file path used by NLME. |
DataMapping |
Mapping of model terms to data column names, which can be:
|
ColDef |
A character string specifying additional column definitions in NLME column definition format. See Phoenix NLME documentation for details. https://onlinehelp.certara.com/phoenix/8.6/index.html#t=Phoenix_UserDocs%2FPML%2FColumn_mappings.htm |
PMLParametersSets |
A list of PML parameters sets ( |
EstArgs |
Estimation arguments for the model template. Please use
|
SimArgs |
Simulation arguments for the model template. Please use
|
Tables |
A list of |
AppendixRows |
Additional rows to include in the model template appendix in NLME column definition format. See Phoenix NLME documentation for details. https://onlinehelp.certara.com/phoenix/8.6/index.html#t=Phoenix_UserDocs%2FPML%2FColumn_mappings.htm |
OmegaSearchBlocks |
A list of character vectors representing omega names to try to build block omegas. |
Mapping Details:
Basic Mapping: Maps a model variable name (e.g., CObs) to a column name
in your data file (e.g., "Concentration").
Shorthand Mapping: If an element is unnamed, the Model Term is assumed
to be the same as the Data Column Term.
Example: c(ID = "Subject", "Age", Weight = "WT") is equivalent to
c(ID = "Subject", Age = "Age", Weight = "WT").
Multiple ID/Grouping Levels: Model terms matching the pattern ID[0-9]?
(i.e., ID, ID0, ID1, ID2, ID3, ID4), case-insensitive, are
automatically recognized by Certara.RsNLME as NLME sort keys/grouping
levels. You can map up to 5 such levels. The function uses these to
structure the model execution.
Covariates: If not explicitly mapped, the function attempts to map them
using data column names that match covariate names in the model.
Mapping a List: When using a list, each vector must map terms specific
to its parameter set, and the list length must equal the number of parameter sets.
Special Terms:
Terms <DosepointName>_Duration or <DosepointName>_Rate
could be used to map rate/duration columns for the corresponding dosepoints
(e.g., A1_Rate = "InfRate"). Term <ObservationName>BQL could be used
to map a BQL flag column for the corresponding observation
(e.g., CObsBQL = "ConcBQL").
The generic AMT term can be used to map the dose amount column;
the function will automatically associate it with the primary absorption
compartment (e.g., A1 for zero-order/bolus, Aa for first-order)
for each parameter set.
Generic Duration or Rate terms can be mapped (e.g., Rate = "InfRate");
the function will associate them with the dose mapped via AMT. If a specific
mapping like A1_Rate exists, it overrides the generic Rate mapping
for that dosepoint (A1).
A list containing statements written to template and tokens files.
specify_EngineParams(), specify_SimParams(), Table()
# Write model template and tokens files PMLParametersSets <- create_ModelPK(CompartmentsNumber = c(1,2)) # write test data frame TempFolder <- tempdir() TemplateFilePath <- file.path(TempFolder, "template.txt") TokensFilePath <- file.path(TempFolder, "tokens.json") DataFilePath <- file.path(TempFolder, "Data.csv") # Ensure data file has columns matching the DataMapping values write.csv(data.frame(Subject = 'id_1', # Column for ID StudyDay = 1, # Column for ID1 time = 0, # Column for time DoseAmt = 100, # Column for AMT Concentration = 10.5, # Column for CObs SubjectAge = 45, # Column for Age Weight = 70, # Column for Weight ConcBQL = 0), # Column for CObsBQL DataFilePath, row.names = FALSE) # Use row.names=FALSE write_ModelTemplateTokens( TemplateFilePath = TemplateFilePath, TokensFilePath = TokensFilePath, Description = "1-2Cpts try with Multi-ID and Shorthand", Author = "Certara", DataFilePath = DataFilePath, DataMapping = c(ID = "Subject", # Map ID model term to Subject column ID1 = "StudyDay", # Map ID1 model term to StudyDay column time = "time", # Map time model term to time column CObs = "Concentration", # Map CObs to Concentration AMT = "DoseAmt", # Map generic AMT to DoseAmt "SubjectAge", # Shorthand: Map Age model term to SubjectAge column Weight = "Weight",# Map Weight model term to Weight column CObsBQL = "ConcBQL"), # Map BQL flag ColDef = "", PMLParametersSets = PMLParametersSets, EstArgs = specify_EngineParams(method = "QRPEM"), SimArgs = specify_SimParams(numReplicates = 1000L), Tables = list(Table(Name = "simtable1.csv", KeepSource = TRUE, VariablesList = "C", ForSimulation = TRUE)), OmegaSearchBlocks = list(c("nCl", "nV"), c("nCl2", "nV2"))) # Multiple parameter sets PMLParametersSets <- create_ModelPK(Absorption =c("Intravenous", "Weibull")) DataMapping <- list( c(ID = "Subject", time = "time", Aa = "DoseAmt", CObs = "Concentration"), c(ID = "Subject", time = "time", A1 = "DoseAmt", CObs = "Concentration") ) names(DataMapping) <- names(PMLParametersSets) write_ModelTemplateTokens( TemplateFilePath = TemplateFilePath, TokensFilePath = TokensFilePath, Description = "1 Cpt Weibull and First-Order", Author = "Certara", DataFilePath = DataFilePath, DataMapping = DataMapping, PMLParametersSets = PMLParametersSets)# Write model template and tokens files PMLParametersSets <- create_ModelPK(CompartmentsNumber = c(1,2)) # write test data frame TempFolder <- tempdir() TemplateFilePath <- file.path(TempFolder, "template.txt") TokensFilePath <- file.path(TempFolder, "tokens.json") DataFilePath <- file.path(TempFolder, "Data.csv") # Ensure data file has columns matching the DataMapping values write.csv(data.frame(Subject = 'id_1', # Column for ID StudyDay = 1, # Column for ID1 time = 0, # Column for time DoseAmt = 100, # Column for AMT Concentration = 10.5, # Column for CObs SubjectAge = 45, # Column for Age Weight = 70, # Column for Weight ConcBQL = 0), # Column for CObsBQL DataFilePath, row.names = FALSE) # Use row.names=FALSE write_ModelTemplateTokens( TemplateFilePath = TemplateFilePath, TokensFilePath = TokensFilePath, Description = "1-2Cpts try with Multi-ID and Shorthand", Author = "Certara", DataFilePath = DataFilePath, DataMapping = c(ID = "Subject", # Map ID model term to Subject column ID1 = "StudyDay", # Map ID1 model term to StudyDay column time = "time", # Map time model term to time column CObs = "Concentration", # Map CObs to Concentration AMT = "DoseAmt", # Map generic AMT to DoseAmt "SubjectAge", # Shorthand: Map Age model term to SubjectAge column Weight = "Weight",# Map Weight model term to Weight column CObsBQL = "ConcBQL"), # Map BQL flag ColDef = "", PMLParametersSets = PMLParametersSets, EstArgs = specify_EngineParams(method = "QRPEM"), SimArgs = specify_SimParams(numReplicates = 1000L), Tables = list(Table(Name = "simtable1.csv", KeepSource = TRUE, VariablesList = "C", ForSimulation = TRUE)), OmegaSearchBlocks = list(c("nCl", "nV"), c("nCl2", "nV2"))) # Multiple parameter sets PMLParametersSets <- create_ModelPK(Absorption =c("Intravenous", "Weibull")) DataMapping <- list( c(ID = "Subject", time = "time", Aa = "DoseAmt", CObs = "Concentration"), c(ID = "Subject", time = "time", A1 = "DoseAmt", CObs = "Concentration") ) names(DataMapping) <- names(PMLParametersSets) write_ModelTemplateTokens( TemplateFilePath = TemplateFilePath, TokensFilePath = TokensFilePath, Description = "1 Cpt Weibull and First-Order", Author = "Certara", DataFilePath = DataFilePath, DataMapping = DataMapping, PMLParametersSets = PMLParametersSets)
This function takes a list of pyDarwin options and writes them to a JSON file
in the specified format. The options can be generated using the
create_pyDarwinOptions function or customized manually. The resulting JSON
file can be used as input for a pyDarwin model search.
write_pyDarwinOptions( pyDarwinOptions = create_pyDarwinOptions(), file = "options.json", pretty = TRUE, digits = NA, auto_unbox = TRUE )write_pyDarwinOptions( pyDarwinOptions = create_pyDarwinOptions(), file = "options.json", pretty = TRUE, digits = NA, auto_unbox = TRUE )
pyDarwinOptions |
A list containing the pyDarwin options to be written
to the JSON file. Default is the result of calling |
file |
Character: The path to the JSON file where the options will be written. Default is a file named "options.json" in the current working directory. |
pretty |
adds indentation whitespace to JSON output. Can be TRUE/FALSE or a number specifying the number of spaces to indent (default is 2). Use a negative number for tabs instead of spaces. |
digits |
max number of decimal digits to print for numeric values. Use |
auto_unbox |
automatically |
None (invisible NULL).
# Write pyDarwin options to a JSON file Options <- create_pyDarwinOptions(author = "John Doe", algorithm = "GA", population_size = 10) write_pyDarwinOptions(Options, file = file.path(tempdir(), "options.json"))# Write pyDarwin options to a JSON file Options <- create_pyDarwinOptions(author = "John Doe", algorithm = "GA", population_size = 10) write_pyDarwinOptions(Options, file = file.path(tempdir(), "options.json"))