relife.freeze#

relife.freeze(model, **kwargs)[source]#

Freeze a parametric model with given arguments.

This function takes a parametric model instance (lifetime model or stochastic process) and stores the given arguments in a new model interface allowing to resquest functions only with time argument.

Parameters:
model: LifetimeRegression, LeftTruncatedModel, AgeReplacementModel or NonHomogeneousPoissonProcess

The model to be frozen. It should be one of the supported model types.

**kwargs: float or np.ndarray

Keyword arguments representing the parameter names and their respective values to be frozen.

Returns:
FrozenLifetimeRegression, FrozenLeftTruncatedModel, FrozenAgeReplacementModel or FrozenNonHomogeneousPoissonProcess

The frozen version of the input model with immutable provided argument values.

Raises:
ValueError

Raised when the provided arguments do not match the expected argument names for the given model, or if the model is not one of the supported types.

Examples

>>> from relife import freeze
>>> from relife.lifetime_model import Weibull, ProportionalHazard
>>> weibull = Weibull(3.5, 0.01)
>>> regression = ProportionalHazard(weibull, coefficients=(1., 2.))
>>> frozen_regression = freeze(regression, covar=1.5)
>>> sf = frozen_regression.sf(np.array([10, 20])) # covar is fixed at 1.5