Coverage for /home/martinb/.local/share/virtualenvs/camcops/lib/python3.6/site-packages/statsmodels/datasets/heart/data.py : 61%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""Heart Transplant Data, Miller 1976"""
2from statsmodels.datasets import utils as du
4__docformat__ = 'restructuredtext'
6COPYRIGHT = """???"""
8TITLE = """Transplant Survival Data"""
10SOURCE = """Miller, R. (1976). Least squares regression with censored data. Biometrica, 63 (3). 449-464.
12"""
14DESCRSHORT = """Survival times after receiving a heart transplant"""
16DESCRLONG = """This data contains the survival time after receiving a heart transplant, the age of the patient and whether or not the survival time was censored.
17"""
19NOTE = """::
21 Number of Observations - 69
23 Number of Variables - 3
25 Variable name definitions::
26 death - Days after surgery until death
27 age - age at the time of surgery
28 censored - indicates if an observation is censored. 1 is uncensored
29"""
32def load(as_pandas=None):
33 """
34 Load the data and return a Dataset class instance.
36 Parameters
37 ----------
38 as_pandas : bool
39 Flag indicating whether to return pandas DataFrames and Series
40 or numpy recarrays and arrays. If True, returns pandas.
42 Returns
43 -------
44 Dataset instance:
45 See DATASET_PROPOSAL.txt for more information.
46 """
47 return du.as_numpy_dataset(load_pandas(), as_pandas=as_pandas)
50def load_pandas():
51 data = _get_data()
52 dataset = du.process_pandas(data, endog_idx=0, exog_idx=None)
53 dataset.censors = dataset.exog.iloc[:, 0]
54 dataset.exog = dataset.exog.iloc[:, 1]
55 return dataset
58def _get_data():
59 return du.load_csv(__file__, 'heart.csv')