statsmodels.duration.hazard_regression.PHReg.from_formula#
- classmethod PHReg.from_formula(formula, data, status=None, entry=None, strata=None, offset=None, subset=None, ties='breslow', missing='drop', *args, **kwargs)[source]#
Create a proportional hazards regression model from a formula and dataframe
- Parameters:
- formula
strorgenericFormulaobject The formula specifying the model
- dataarray_like
The data for the model. See Notes.
- statusarray_like,
optional The censoring status values; status=1 indicates that an event occurred (e.g., failure or death), status=0 indicates that the observation was right censored. If None, defaults to status=1 for all cases.
- entryarray_like,
optional The entry times, if left truncation occurs
- strataarray_like,
optional Stratum labels. If None, all observations are taken to be in a single stratum.
- offsetarray_like,
optional Array of offset values
- subsetarray_like,
optional An array-like object of booleans, integers, or index values that indicate the subset of df to use in the model. Assumes df is a pandas.DataFrame
- ties{‘breslow’, ‘efron’},
optional The method used to handle tied times.
- missing
str,optional The method used to handle missing data
- args
extraarguments These are passed to the model
- kwargs
extrakeywordarguments These are passed to the model with one exception. The
eval_envkeyword is passed to patsy. It can be either apatsy:patsy.EvalEnvironmentobject or an integer indicating the depth of the namespace to use. For example, the defaulteval_env=0uses the calling namespace. If you wish to use a “clean” environment seteval_env=-1.
- formula
- Returns:
- model
PHRegmodelinstance
- model
Notes
data must define __getitem__ with the keys in the formula terms args and kwargs are passed on to the model instantiation. E.g., a numpy structured or rec array, a dictionary, or a pandas DataFrame.