ehrapy.tools.ols¶
- ehrapy.tools.ols(adata, var_names=None, formula=None, missing='none')[source]¶
Create an Ordinary Least Squares (OLS) Model from a formula and AnnData.
- Parameters:
adata (
AnnData) – The AnnData object for the OLS model.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.missing (
Optional[Literal['none','drop','raise']], 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:
OLS- Returns:
The OLS model instance.
Examples
>>> import ehrapy as ep >>> adata = ep.dt.mimic_2(encoded=False) >>> formula = "tco2_first ~ pco2_first" >>> var_names = ["tco2_first", "pco2_first"] >>> ols = ep.tl.ols(adata, var_names, formula, missing="drop")