Coverage for /home/martinb/.local/share/virtualenvs/camcops/lib/python3.6/site-packages/statsmodels/datasets/spector/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"""Spector and Mazzeo (1980) - Program Effectiveness Data"""
2from statsmodels.datasets import utils as du
4__docformat__ = 'restructuredtext'
6COPYRIGHT = """Used with express permission of the original author, who
7retains all rights. """
8TITLE = __doc__
9SOURCE = """
10http://pages.stern.nyu.edu/~wgreene/Text/econometricanalysis.htm
12The raw data was downloaded from Bill Greene's Econometric Analysis web site,
13though permission was obtained from the original researcher, Dr. Lee Spector,
14Professor of Economics, Ball State University."""
16DESCRSHORT = """Experimental data on the effectiveness of the personalized
17system of instruction (PSI) program"""
19DESCRLONG = DESCRSHORT
21NOTE = """::
23 Number of Observations - 32
25 Number of Variables - 4
27 Variable name definitions::
29 Grade - binary variable indicating whether or not a student's grade
30 improved. 1 indicates an improvement.
31 TUCE - Test score on economics test
32 PSI - participation in program
33 GPA - Student's grade point average
34"""
37def load(as_pandas=None):
38 """
39 Load the Spector dataset and returns a Dataset class instance.
41 Parameters
42 ----------
43 as_pandas : bool
44 Flag indicating whether to return pandas DataFrames and Series
45 or numpy recarrays and arrays. If True, returns pandas.
47 Returns
48 -------
49 Dataset instance:
50 See DATASET_PROPOSAL.txt for more information.
51 """
52 return du.as_numpy_dataset(load_pandas(), as_pandas=as_pandas)
55def load_pandas():
56 """
57 Load the Spector dataset and returns a Dataset class instance.
59 Returns
60 -------
61 Dataset instance:
62 See DATASET_PROPOSAL.txt for more information.
63 """
64 data = _get_data()
65 return du.process_pandas(data, endog_idx=3)
68def _get_data():
69 data = du.load_csv(__file__, 'spector.csv', sep=r'\s')
70 data = du.strip_column_names(data)
71 data = data.iloc[:, [1, 2, 3, 4]]
72 return data.astype(float)