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

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"""Longley dataset"""
2from statsmodels.datasets import utils as du
4__docformat__ = 'restructuredtext'
6COPYRIGHT = """This is public domain."""
7TITLE = __doc__
8SOURCE = """
9The classic 1967 Longley Data
11http://www.itl.nist.gov/div898/strd/lls/data/Longley.shtml
13::
15 Longley, J.W. (1967) "An Appraisal of Least Squares Programs for the
16 Electronic Comptuer from the Point of View of the User." Journal of
17 the American Statistical Association. 62.319, 819-41.
18"""
20DESCRSHORT = """"""
22DESCRLONG = """The Longley dataset contains various US macroeconomic
23variables that are known to be highly collinear. It has been used to appraise
24the accuracy of least squares routines."""
26NOTE = """::
28 Number of Observations - 16
30 Number of Variables - 6
32 Variable name definitions::
34 TOTEMP - Total Employment
35 GNPDEFL - GNP deflator
36 GNP - GNP
37 UNEMP - Number of unemployed
38 ARMED - Size of armed forces
39 POP - Population
40 YEAR - Year (1947 - 1962)
41"""
45def load(as_pandas=None):
46 """
47 Load the Longley data and return a Dataset class.
49 Parameters
50 ----------
51 as_pandas : bool
52 Flag indicating whether to return pandas DataFrames and Series
53 or numpy recarrays and arrays. If True, returns pandas.
55 Returns
56 -------
57 Dataset instance
58 See DATASET_PROPOSAL.txt for more information.
59 """
60 return du.as_numpy_dataset(load_pandas(), as_pandas=as_pandas)
63def load_pandas():
64 """
65 Load the Longley data and return a Dataset class.
67 Returns
68 -------
69 Dataset instance
70 See DATASET_PROPOSAL.txt for more information.
71 """
72 data = _get_data()
73 return du.process_pandas(data, endog_idx=0)
76def _get_data():
77 data = du.load_csv(__file__, 'longley.csv')
78 data = data.iloc[:, [1, 2, 3, 4, 5, 6, 7]].astype(float)
79 return data