jmstate.types.SampleData

class SampleData(x, trajectories, indiv_params, t_cond=None)[source]

Dataclass containing individual-level data for sampling procedures.

It can be used with scikit-learn’s train-test splits or cross-validation utilities.

Covariates:
  • x is a matrix of covariates of shape \((n, p)\), where \(n\) denotes the number of individuals and \(p\) the number of covariates.

Trajectories:
  • trajectories contains the individual-level multistate trajectories. They correspond to a list[list[tuple[float, Any]]] where each inner list is a trajectory and each tuple is a (time, state) pair.

Individual Parameters:
  • indiv_params represents the individual-specific parameters. It is expected to have the same number of rows as there are trajectories. Use a 3D tensor only if you fully understand the codebase and mechanisms. Trajectory sampling may only be used with matrices.

Conditioning Times:
  • t_cond corresponds to truncation or conditioning times for each individual. This attribute is optional and, if not provided, is set to the maximum observation time per individual. This represents a landmark time up to which we condition on having observed no transitions. All simulated event times for the individual will be greater than or equal to t_cond.

The data class is used for simulation and for prediction of quantities related to survival functions or trajectories. Unlike ModelData, it assumes exact knowledge of the individual parameters.

Raises:
  • ValueError – If some trajectory is empty.

  • ValueError – If some trajectory is not sorted.

  • ValueError – If some trajectory is not compatible with the conditioning times.

  • ValueError – If any of the inputs contain NaN or infinite values.

  • ValueError – If the size is not consistent between inputs.

Variables:
  • x (torch.Tensor) – Fixed covariate matrix of shape (n, p), where n is the number of individuals and p the number of covariates.

  • trajectories (list[Trajectory]) – List of individual trajectories. Each Trajectory consists of a sequence of (time, state) tuples.

  • indiv_params (torch.Tensor) – Individual parameters with the same number of rows as there are trajectories. Use a matrix by default.

  • t_cond (torch.Tensor | None) – Optional conditioning times per individual. If None, the maximum observation time is used.

Parameters:
  • x (Tensor)

  • trajectories (list[list[tuple[float, str]]])

  • indiv_params (Tensor)

  • t_cond (Tensor | None)

__init__(x, trajectories, indiv_params, t_cond=None)
Parameters:
  • x (Tensor)

  • trajectories (list[list[tuple[float, str]]])

  • indiv_params (Tensor)

  • t_cond (Tensor | None)

Return type:

None