Hide keyboard shortcuts

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 

3 

4__docformat__ = 'restructuredtext' 

5 

6COPYRIGHT = """???""" 

7 

8TITLE = """Transplant Survival Data""" 

9 

10SOURCE = """Miller, R. (1976). Least squares regression with censored data. Biometrica, 63 (3). 449-464. 

11 

12""" 

13 

14DESCRSHORT = """Survival times after receiving a heart transplant""" 

15 

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""" 

18 

19NOTE = """:: 

20 

21 Number of Observations - 69 

22 

23 Number of Variables - 3 

24 

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""" 

30 

31 

32def load(as_pandas=None): 

33 """ 

34 Load the data and return a Dataset class instance. 

35 

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. 

41 

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) 

48 

49 

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 

56 

57 

58def _get_data(): 

59 return du.load_csv(__file__, 'heart.csv')