leaspy.models.joint

Classes

JointModel

Joint model for multiple repeated measures (logistic) and multiple competing events.

Module Contents

class JointModel(name, **kwargs)[source]

Bases: leaspy.models.logistic.LogisticModel

Joint model for multiple repeated measures (logistic) and multiple competing events. The model implemented is associated to this [publication](https://arxiv.org/abs/2501.08960) on arxiv.

Parameters:
namestr

The name of the model.

**kwargs

Hyperparameters of the model (including noise_model)

Raises:
LeaspyModelInputError
  • If name is not one of allowed sub-type: ‘univariate_linear’ or ‘univariate_logistic’

  • If hyperparameters are inconsistent

Parameters:

name (str)

init_tolerance: float = 0.3
get_variables_specs()[source]

Return the specifications of the variables (latent variables, derived variables, model ‘parameters’) that are part of the model.

Returns:
NamedVariables

The specifications of the model’s variables.

Return type:

NamedVariables

to_dict(*, with_mixing_matrix=True)[source]

Export model as a dictionary ready for export. Add the number of events compare to the multivariate output

Parameters:
with_mixing_matrixbool

If True the mixing matrix will be saved in the dictionary

Returns:
KwargsType

The model instance serialized as a dictionary.

Parameters:

with_mixing_matrix (bool)

Return type:

KwargsType

put_individual_parameters(state, dataset)[source]

Initialise the individual parameters of the state thanks to the dataset.

Parameters:
stateState

where all the variables of the model are stored

datasetDataset

Where the individual data are stored

Returns:
None
Parameters:
compute_individual_trajectory(timepoints, individual_parameters, *, skip_ips_checks=False)[source]

This method computes the individual trajectory of a patient for given timepoint(s) using his/her individual parameters (random effects). For the longitudinal sub-model:

  • Compute longitudinal values

For the event sub-model:
  • only one event: return the survival rate corrected by the probability of the first time point of the prediction assuming that the patient was alive,

  • more than one event: return the Cumulative Incidence function corrected by the probability of the first time point of the prediction assuming that the patient was alive.

Nota: model uses its current internal state.

Parameters:
timepointsscalar or array_like[scalar] (list, tuple, numpy.ndarray)

Contains the age(s) of the subject.

individual_parametersdict

Contains the individual parameters. Each individual parameter should be a scalar or array_like.

skip_ips_checksbool (default: False)

Flag to skip consistency/compatibility checks and tensorization of individual_parameters when it was done earlier (speed-up).

Returns:
torch.Tensor

Contains the subject’s scores computed at the given age(s) Shape of tensor is (1, n_tpts, n_features).

Raises:
LeaspyModelInputError

If computation is tried on more than 1 individual.

LeaspyIndividualParamsInputError

if invalid individual parameters.

Parameters:
Return type:

Tensor