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"""World Copper Prices 1951-1975 dataset.""" 

2from statsmodels.datasets import utils as du 

3 

4__docformat__ = 'restructuredtext' 

5 

6COPYRIGHT = """Used with express permission from the original author, 

7who retains all rights.""" 

8TITLE = "World Copper Market 1951-1975 Dataset" 

9SOURCE = """ 

10Jeff Gill's `Generalized Linear Models: A Unified Approach` 

11 

12http://jgill.wustl.edu/research/books.html 

13""" 

14 

15DESCRSHORT = """World Copper Market 1951-1975""" 

16 

17DESCRLONG = """This data describes the world copper market from 1951 through 1975. In an 

18example, in Gill, the outcome variable (of a 2 stage estimation) is the world 

19consumption of copper for the 25 years. The explanatory variables are the 

20world consumption of copper in 1000 metric tons, the constant dollar adjusted 

21price of copper, the price of a substitute, aluminum, an index of real per 

22capita income base 1970, an annual measure of manufacturer inventory change, 

23and a time trend. 

24""" 

25 

26NOTE = """ 

27Number of Observations - 25 

28 

29Number of Variables - 6 

30 

31Variable name definitions:: 

32 

33 WORLDCONSUMPTION - World consumption of copper (in 1000 metric tons) 

34 COPPERPRICE - Constant dollar adjusted price of copper 

35 INCOMEINDEX - An index of real per capita income (base 1970) 

36 ALUMPRICE - The price of aluminum 

37 INVENTORYINDEX - A measure of annual manufacturer inventory trend 

38 TIME - A time trend 

39 

40Years are included in the data file though not returned by load. 

41""" 

42 

43 

44def _get_data(): 

45 data = du.load_csv(__file__, 'copper.csv') 

46 data = data.iloc[:, 1:7] 

47 return data.astype(float) 

48 

49 

50def load_pandas(): 

51 """ 

52 Load the copper data and returns a Dataset class. 

53 

54 Returns 

55 ------- 

56 Dataset instance: 

57 See DATASET_PROPOSAL.txt for more information. 

58 """ 

59 data = _get_data() 

60 return du.process_pandas(data, endog_idx=0) 

61 

62 

63def load(as_pandas=None): 

64 """ 

65 Load the copper data and returns a Dataset class. 

66 

67 Parameters 

68 ---------- 

69 as_pandas : bool 

70 Flag indicating whether to return pandas DataFrames and Series 

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

72 

73 Returns 

74 ------- 

75 Dataset instance: 

76 See DATASET_PROPOSAL.txt for more information. 

77 """ 

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