FrozenLifetimeRegression#
- class relife.lifetime_model.FrozenLifetimeRegression(regression, covar, *args)[source]#
Frozen lifetime regression.
- Parameters:
- regressionLifetimeRegression
Any lifetime regression.
- covarfloat or np.ndarray
Covariate values to be frozen.
- *argsfloat or np.ndarray
Additional arguments needed by the model to be frozen.
- Attributes:
- unfrozen_modelLifetimeRegression
The unfrozen regression model.
- argstuple of float or np.ndarray
All the frozen arguments given and necessary to compute model functions.
- nb_assetsint
Number of assets passed in frozen arguments. The data is mainly used to control numpy broadcasting and may not interest an user.
Warning
This class is documented for the purpose of clarity and mainly address contributors or advance users. Actually, the recommanded way to instanciate a
FrozenLifetimeRegression
is use tofreeze
factory function.Methods
The cumulative density function.
The cumulative hazard function.
The derivate of the hazard function.
The hazard function.
Inverse cumulative hazard function.
The inverse survival function.
The jacobian of the cumulative density function.
The jacobian of the cumulative hazard function.
The jacobian of the hazard function.
The jacobian of the probability density function.
The jacobian of the survival function.
Lebesgue-Stieltjes integration.
The mean.
The median.
n-th order moment.
The mean residual life function.
The probability density function.
The percent point function.
Random variable sampling.
The survival function.
unfreeze
The variance.
- cdf(time)#
The cumulative density function.
- Parameters:
- timefloat or np.ndarray
Elapsed time value(s) at which to compute the function. If ndarray, allowed shapes are
()
,(n,)
or(m, n)
.
- Returns:
- np.float64 or np.ndarray
Function values at each given time(s).
- chf(time)#
The cumulative hazard function.
- Parameters:
- timefloat or np.ndarray
Elapsed time value(s) at which to compute the function. If ndarray, allowed shapes are
()
,(n,)
or(m, n)
.
- Returns:
- np.float64 or np.ndarray
Function values at each given time(s).
- dhf(time)[source]#
The derivate of the hazard function.
- Parameters:
- timefloat or np.ndarray
Elapsed time value(s) at which to compute the function. If ndarray, allowed shapes are
()
,(n,)
or(m, n)
.
- Returns:
- np.float64 or np.ndarray
Function values at each given time(s).
- hf(time)#
The hazard function.
- Parameters:
- timefloat or np.ndarray
Elapsed time value(s) at which to compute the function. If ndarray, allowed shapes are
()
,(n,)
or(m, n)
.
- Returns:
- np.float64 or np.ndarray
Function values at each given time(s).
- ichf(cumulative_hazard_rate)#
Inverse cumulative hazard function.
- Parameters:
- cumulative_hazard_ratefloat or np.ndarray
Cumulative hazard rate value(s) at which to compute the function. If ndarray, allowed shapes are (), (n,) or (m, n).
- Returns:
- np.float64 or np.ndarray
Function values at each given probability value(s).
- isf(probability)#
The inverse survival function.
- Parameters:
- probabilityfloat or np.ndarray
Probability value(s) at which to compute the function. If ndarray, allowed shapes are
()
,(n,)
or(m, n)
.
- Returns:
- np.float64 or np.ndarray
Function values at each given probability value(s).
- jac_cdf(time, asarray=False)[source]#
The jacobian of the cumulative density function.
- Parameters:
- timefloat or np.ndarray
Elapsed time value(s) at which to compute the function. If ndarray, allowed shapes are
()
,(n,)
or(m, n)
.- asarraybool, default is False
- Returns:
- np.float64, np.ndarray or tuple of np.float64 or np.ndarray
The derivatives with respect to each parameter. If
asarray
is False, the function returns a tuple containing the same number of elements as parameters. Ifasarray
is True, the function returns an ndarray whose first dimension equals the number of parameters. This output is equivalent to applyingnp.stack
on the output tuple whenasarray
is False.
- jac_chf(time, asarray=False)[source]#
The jacobian of the cumulative hazard function.
- Parameters:
- timefloat or np.ndarray
Elapsed time value(s) at which to compute the function. If ndarray, allowed shapes are
()
,(n,)
or(m, n)
.- asarraybool, default is False
- Returns:
- np.float64, np.ndarray or tuple of np.float64 or np.ndarray
The derivatives with respect to each parameter. If
asarray
is False, the function returns a tuple containing the same number of elements as parameters. Ifasarray
is True, the function returns an ndarray whose first dimension equals the number of parameters. This output is equivalent to applyingnp.stack
on the output tuple whenasarray
is False.
- jac_hf(time, asarray=False)[source]#
The jacobian of the hazard function.
- Parameters:
- timefloat or np.ndarray
Elapsed time value(s) at which to compute the function. If ndarray, allowed shapes are
()
,(n,)
or(m, n)
.- asarraybool, default is False
- Returns:
- np.float64, np.ndarray or tuple of np.float64 or np.ndarray
The derivatives with respect to each parameter. If
asarray
is False, the function returns a tuple containing the same number of elements as parameters. Ifasarray
is True, the function returns an ndarray whose first dimension equals the number of parameters. This output is equivalent to applyingnp.stack
on the output tuple whenasarray
is False.
- jac_pdf(time, asarray=False)[source]#
The jacobian of the probability density function.
- Parameters:
- timefloat or np.ndarray
Elapsed time value(s) at which to compute the function. If ndarray, allowed shapes are
()
,(n,)
or(m, n)
.- asarraybool, default is False
- Returns:
- np.float64, np.ndarray or tuple of np.float64 or np.ndarray
The derivatives with respect to each parameter. If
asarray
is False, the function returns a tuple containing the same number of elements as parameters. Ifasarray
is True, the function returns an ndarray whose first dimension equals the number of parameters. This output is equivalent to applyingnp.stack
on the output tuple whenasarray
is False.
- jac_sf(time, asarray=False)[source]#
The jacobian of the survival function.
- Parameters:
- timefloat or np.ndarray
Elapsed time value(s) at which to compute the function. If ndarray, allowed shapes are
()
,(n,)
or(m, n)
.- asarraybool, default is False
- Returns:
- np.float64, np.ndarray or tuple of np.float64 or np.ndarray
The derivatives with respect to each parameter. If
asarray
is False, the function returns a tuple containing the same number of elements as parameters. Ifasarray
is True, the function returns an ndarray whose first dimension equals the number of parameters. This output is equivalent to applyingnp.stack
on the output tuple whenasarray
is False.
- ls_integrate(func, a, b, deg=10)#
Lebesgue-Stieltjes integration.
- Parameters:
- funccallable (in1 ndarray , out1 ndarray)
The callable must have only one ndarray object as argument and one ndarray object as output
- andarray (maximum number of dimension is 2)
Lower bound(s) of integration.
- bndarray (maximum number of dimension is 2)
Upper bound(s) of integration. If lower bound(s) is infinite, use np.inf as value.)
- degint, default 10
Degree of the polynomials interpolation
- Returns:
- np.ndarray
Lebesgue-Stieltjes integral of func from a to b.
- mean()#
The mean.
- Returns:
- np.float64 or np.ndarray
- median()#
The median.
- Returns:
- np.float64 or np.ndarray
- moment(n)#
n-th order moment.
- Parameters:
- nint
Order of the moment (at least 1)
- Returns:
- np.float64 or np.ndarray
- mrl(time)#
The mean residual life function.
- Parameters:
- timefloat or np.ndarray
Elapsed time value(s) at which to compute the function. If ndarray, allowed shapes are
()
,(n,)
or(m, n)
.
- Returns:
- np.float64 or np.ndarray
Function values at each given time(s).
- property nb_coef#
The number of coefficients
- Returns:
- int
- property nb_params#
Number of parameters.
- Returns:
- int
Number of parameters.
- property params#
Parameters values.
- Returns:
- ndarray
Parameters values of the core
Notes
If parameter values are not set, they are encoded as np.nan value.
Parameters can be by manually setting`params` through its setter, fitting the core if fit exists or by specifying all parameters values when the core object is initialized.
- property params_names#
Parameters names.
- Returns:
- list of str
Parameters names
Notes
Parameters values can be requested (a.k.a. get) by their name at instance level.
- pdf(time)#
The probability density function.
- Parameters:
- timefloat or np.ndarray
Elapsed time value(s) at which to compute the function. If ndarray, allowed shapes are
()
,(n,)
or(m, n)
.
- Returns:
- np.float64 or np.ndarray
Function values at each given time(s).
- ppf(probability)#
The percent point function.
- Parameters:
- probabilityfloat or np.ndarray
Probability value(s) at which to compute the function. If ndarray, allowed shapes are
()
,(n,)
or(m, n)
.
- Returns:
- np.float64 or np.ndarray
Function values at each given probability value(s).
- rvs(size, return_event=False, return_entry=False, seed=None)#
Random variable sampling.
- Parameters:
- sizeint, (int,) or (int, int)
Size of the generated sample. If size is
n
or(n,)
, n samples are generated. If size is(m,n)
, a 2d array of samples is generated.- return_eventbool, default is False
If True, returns event indicators along with the sample time values.
- return_entrybool, default is False
If True, returns corresponding entry values of the sample time values.
- seedoptional int, default is None
Random seed used to fix random sampling.
- Returns:
- float, ndarray or tuple of float or ndarray
The sample values. If either
return_event
orreturn_entry
is True, returns a tuple containing the time values followed by event values, entry values or both.
- sf(time)#
The survival function.
- Parameters:
- timefloat or np.ndarray
Elapsed time value(s) at which to compute the function. If ndarray, allowed shapes are
()
,(n,)
or(m, n)
.
- Returns:
- np.float64 or np.ndarray
Function values at each given time(s).
- var()#
The variance.
- Returns:
- np.float64 or np.ndarray