ehrapy.tools.ols#
- ehrapy.tools.ols(edata, var_names=None, formula=None, *, missing='none', use_feature_types=False, layer=None)[source]#
Create an Ordinary Least Squares (OLS) Model from a formula and the data object.
- Parameters:
var_names (
list[str] |None, default:None) – A list of var names indicating which columns are for the OLS model.formula (
str|None, default:None) – The formula specifying the model.use_feature_types (
bool, default:False) – If True, the feature types in the data objects .var are used.missing (
Literal['none','drop','raise'] |None, default:'none') – Available options are ‘none’, ‘drop’, and ‘raise’. If ‘none’, no nan checking is done. If ‘drop’, any observations with nans are dropped. If ‘raise’, an error is raised.
- Return type:
- Returns:
The OLS model instance.
Examples
>>> import ehrdata as ed >>> import ehrapy as ep >>> edata = ed.dt.mimic_2() >>> formula = "tco2_first ~ pco2_first" >>> var_names = ["tco2_first", "pco2_first"] >>> ols = ep.tl.ols(edata, var_names, formula, missing="drop")