Model#

class pharmpy.model.Model(name='', parameters=Parameters(), random_variables=, statements=, dataset=None, datainfo=Empty DataFrame Columns: [name, type, scale, continuous, categories, unit, drop, datatype, descriptor] Index: [], dependent_variables={y: 1}, observation_transformation=None, estimation_steps=EstimationSteps(), parent_model=None, initial_individual_estimates=None, filename_extension='', value_type='PREDICTION', description='', internals=None)[source]#

Bases: Immutable

The Pharmpy model class

Attributes Summary

datainfo

Definitions of model statements

dataset

Dataset connected to model

dependent_variables

The dependent variables of the model mapped to the corresponding DVIDs

description

A free text description of the model

estimation_steps

Definitions of estimation steps

filename_extension

Filename extension of model file

initial_individual_estimates

Initial estimates for individual parameters

internals

Internal data for tool specific part of model

model_code

Model type specific code

name

Name of the model

observation_transformation

Transformation to be applied to the observation data

parameters

Definitions of population parameters

parent_model

Name of parent model

random_variables

Definitions of random variables

statements

Definitions of model statements

value_type

The type of the model value (dependent variables)

Methods Summary

create(name[, parameters, random_variables, ...])

from_dict(d)

has_same_dataset_as(other)

Check if this model has the same dataset as another model

parse_model(path)

Create a model object by parsing a model file of any supported type

parse_model_from_string(code)

Create a model object by parsing a string with model code of any supported type

replace(**kwargs)

to_dict()

update_source()

Update source code of the model.

write_files([path, force])

Write all extra files needed for a specific external format.

Attributes Documentation

datainfo#

Definitions of model statements

See pharmpy.Statements

dataset#

Dataset connected to model

dependent_variables#

The dependent variables of the model mapped to the corresponding DVIDs

description#

A free text description of the model

estimation_steps#

Definitions of estimation steps

See pharmpy.EstimationSteps

filename_extension#

Filename extension of model file

initial_individual_estimates#

Initial estimates for individual parameters

internals#

Internal data for tool specific part of model

model_code#

Model type specific code

name#

Name of the model

observation_transformation#

Transformation to be applied to the observation data

parameters#

Definitions of population parameters

See pharmpy.Parameters

parent_model#

Name of parent model

random_variables#

Definitions of random variables

See pharmpy.RandomVariables

statements#

Definitions of model statements

See pharmpy.Statements

value_type#

The type of the model value (dependent variables)

By default this is set to ‘PREDICTION’ to mean that the model outputs a prediction. It could optionally be set to ‘LIKELIHOOD’ or ‘-2LL’ to let the model output the likelihood or -2*log(likelihood) of the prediction. If set to a symbol this variable can be used to change the type for different records. The model would then set this symbol to 0 for a prediction value, 1 for likelihood and 2 for -2ll.

Methods Documentation

classmethod create(name, parameters=None, random_variables=None, statements=None, dataset=None, datainfo=Empty DataFrame Columns: [name, type, scale, continuous, categories, unit, drop, datatype, descriptor] Index: [], dependent_variables=None, observation_transformation=None, estimation_steps=None, parent_model=None, initial_individual_estimates=None, filename_extension='', value_type='PREDICTION', description='', internals=None)[source]#
classmethod from_dict(d)[source]#
has_same_dataset_as(other)[source]#

Check if this model has the same dataset as another model

Parameters:

other (Model) – Another model

Returns:

bool – True if both models have the same dataset

static parse_model(path)[source]#

Create a model object by parsing a model file of any supported type

Parameters:

path (Path or str) – Path to a model file

Returns:

Model – A model object

static parse_model_from_string(code)[source]#

Create a model object by parsing a string with model code of any supported type

Parameters:

code (str) – Model code

Returns:

Model – A model object

replace(**kwargs)[source]#
to_dict()[source]#
update_source()[source]#

Update source code of the model. If any paths need to be changed or added (e.g. for a NONMEM model with an updated dataset) they will be replaced with DUMMYPATH

write_files(path=None, force=False)[source]#

Write all extra files needed for a specific external format.