pharmpy.model module

Generic Model class

Base class of all implementations.

Inherit to implement, i.e. to define support for a specific model type. Duck typing is utilized, but an implementation is expected to implement all methods/attributes.

Definitions

class pharmpy.model.Model[source]

Bases: object

Attribute: name

dependent_variable parameters random_variables statements dataset

bump_model_number(path='.')[source]

If the model name ends in a number increase it to next available file else do nothing.

copy()[source]

Create a deepcopy of the model object

property covariates

List of covariates used in model

create_symbol(stem, force_numbering=False)[source]

Create a new unique variable symbol

Parameters
  • stem (str) – First part of the new variable name

  • force_numbering (bool) – Forces addition of number to name even if variable does not exist, e.g. COVEFF –> COVEFF1

property data_transformation

Transformation used for DV in dataset

eps_gradient(etas=None, parameters=None, dataset=None)[source]

Numeric epsilon gradient

eta_gradient(etas=None, parameters=None, dataset=None)[source]

Numeric eta gradient

The gradient is evaluated given initial etas, parameters and the model dataset. The arguments etas, parameters and dataset can optionally override those of the model. Return a DataFrame of gradients.

individual_prediction(etas=None, parameters=None, dataset=None)[source]

Numeric individual prediction

property modelfit_results
population_prediction(parameters=None, dataset=None)[source]

Numeric population prediction

The prediction is evaluated at the current model parameter values or optionally at the given parameter values. The evaluation is done for each data record in the model dataset or optionally using the dataset argument.

Return population prediction series

read_raw_dataset(parse_columns=())[source]
remove_unused_parameters_and_rvs()[source]

Remove any parameters and rvs that are not used in the model statements

symbolic_eps_gradient()[source]
symbolic_eta_gradient()[source]
symbolic_individual_prediction()[source]

Symbolic model individual prediction

symbolic_population_prediction()[source]

Symbolic model population prediction

to_generic_model()[source]

Convert a model into the base model class

update_individual_estimates(source)[source]
update_inits()[source]

Update inital estimates of model from its own ModelfitResults

update_source()[source]

Update the source

weighted_residuals(parameters=None, dataset=None)[source]
write(path='', force=False)[source]

Write model to file using its source format If no path is supplied or does not contain a filename a name is created from the name property of the model Will not overwrite in case force is True. return path written to

exception pharmpy.model.ModelException[source]

Bases: Exception

exception pharmpy.model.ModelSyntaxError(msg='model syntax error')[source]

Bases: pharmpy.model.ModelException

pharmpy.model.canonicalize_data_transformation(model, value)[source]

Inheritance Diagram

Inheritance diagram of pharmpy.model