Skip to contents

Creates (or overwrites) a textual metamodel file (e.g. .mmdl) from a supplied NlmePmlModel object. This is the inverse of read_mmdl().

Usage

create_metamodel_from_model(
  model,
  metamodelFile,
  datafile,
  author = "",
  engineParams = NULL,
  tableParams = NULL,
  absolutePaths = FALSE
)

Arguments

model

An NlmePmlModel object.

metamodelFile

Output metamodel file path to create/overwrite.

datafile

Input data file path to write into the ## DATA block.

author

Optional author string to write into the metamodel.

engineParams

Optional NlmeEngineExtraParams object created by engineParams() to serialize into the ## ESTARGS block. Only arguments that differ from engineParams() defaults for this model (and estimation method) are written.

tableParams

Optional table definition(s) created by tableParams() (i.e., NlmeTableDef and/or NlmeSimTableDef, or a list of them) to serialize into the ## TABLES block.

absolutePaths

Logical; controls how datafile is written into the ## DATA block. FALSE (default) writes a path relative to the metamodel directory (e.g. ./data.csv), keeping the resulting metamodel portable across machines. TRUE writes a normalized absolute path, useful when the dataset lives outside the metamodel tree (shared drive, central data location). When relative resolution is not possible (e.g. different Windows drive), the function warns and falls back to an absolute path.

Value

Invisible model.

Examples

if (FALSE) { # \dontrun{
tmp_data <- tempfile(fileext = ".csv")
write.csv(Certara.RsNLME::pkData, tmp_data, row.names = FALSE)

m <- Certara.RsNLME::pkmodel(data = Certara.RsNLME::pkData, workingDir = tempdir())
ep <- Certara.RsNLME::engineParams(m, method = "FOCE-ELS", numIterations = 200)

out_mmdl <- file.path(tempdir(), "example.mmdl")
Certara.RsNLME::create_metamodel_from_model(m, out_mmdl, datafile = tmp_data, engineParams = ep)
} # }