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"""Fair's Extramarital Affairs Data""" 

2from statsmodels.datasets import utils as du 

3 

4__docformat__ = 'restructuredtext' 

5 

6COPYRIGHT = """Included with permission of the author.""" 

7TITLE = """Affairs dataset""" 

8SOURCE = """ 

9Fair, Ray. 1978. "A Theory of Extramarital Affairs," `Journal of Political 

10Economy`, February, 45-61. 

11 

12The data is available at http://fairmodel.econ.yale.edu/rayfair/pdf/2011b.htm 

13""" 

14 

15DESCRSHORT = """Extramarital affair data.""" 

16 

17DESCRLONG = """Extramarital affair data used to explain the allocation 

18of an individual's time among work, time spent with a spouse, and time 

19spent with a paramour. The data is used as an example of regression 

20with censored data.""" 

21 

22#suggested notes 

23NOTE = """:: 

24 

25 Number of observations: 6366 

26 Number of variables: 9 

27 Variable name definitions: 

28 

29 rate_marriage : How rate marriage, 1 = very poor, 2 = poor, 3 = fair, 

30 4 = good, 5 = very good 

31 age : Age 

32 yrs_married : No. years married. Interval approximations. See 

33 original paper for detailed explanation. 

34 children : No. children 

35 religious : How relgious, 1 = not, 2 = mildly, 3 = fairly, 

36 4 = strongly 

37 educ : Level of education, 9 = grade school, 12 = high 

38 school, 14 = some college, 16 = college graduate, 

39 17 = some graduate school, 20 = advanced degree 

40 occupation : 1 = student, 2 = farming, agriculture; semi-skilled, 

41 or unskilled worker; 3 = white-colloar; 4 = teacher 

42 counselor social worker, nurse; artist, writers; 

43 technician, skilled worker, 5 = managerial, 

44 administrative, business, 6 = professional with 

45 advanced degree 

46 occupation_husb : Husband's occupation. Same as occupation. 

47 affairs : measure of time spent in extramarital affairs 

48 

49 See the original paper for more details. 

50""" 

51 

52 

53def load(as_pandas=None): 

54 """ 

55 Load the data and return a Dataset class instance. 

56 

57 Parameters 

58 ---------- 

59 as_pandas : bool 

60 Flag indicating whether to return pandas DataFrames and Series 

61 or numpy recarrays and arrays. If True, returns pandas. 

62 

63 Returns 

64 ------- 

65 Dataset instance: 

66 See DATASET_PROPOSAL.txt for more information. 

67 """ 

68 return du.as_numpy_dataset(load_pandas(), as_pandas=as_pandas) 

69 

70 

71def load_pandas(): 

72 data = _get_data() 

73 return du.process_pandas(data, endog_idx=8, exog_idx=None) 

74 

75 

76def _get_data(): 

77 return du.load_csv(__file__, 'fair.csv', convert_float=True)