Content
. /**
> * A do file to run the standard stats for a whole data set.
> *
> * Note that you must delete the files in the derived directory
> * for changes to be reflected in the output.
> *
> * @version 0.1
> */
.
. // profiler on
.
. use "/home/schaffne/Dropbox/Public/efn508/additionaldatafiles/dailyspreads.dta"
.
. describe, short
Contains data from /home/schaffne/Dropbox/Public/efn508/additionaldatafiles/dailyspreads.dta
obs: 3,938
vars: 2 16 Apr 2012 23:34
size: 31,504
Sorted by:
.
. local N = r(N)
. local variables = r(k)
.
. di "@N `N'"
@N 3938
. di "@variables `variables'"
@variables 2
.
. datasignature
3938:2(27422):3780684525:1267828961
. local datasig = "`r(datasignature)'"
.
. di "@datasignature `datasig'"
@datasignature 3938:2(27422):3780684525:1267828961
.
. cap noi xtset
panel variable not set; use xtset varname ...
. if ( !_rc ) {
. di "@timevar `r(timevar)'"
. di "@panelvar `r(panelvar)'"
. }
.
. notes _dta
.
. qui {
.
. foreach var of varlist * {
2.
. di "=====`var'====="
3. qui {
4. local category_cutoff = 100
5.
. // this takes very long on large datasets (and does mostly the same as other things below)
. // codebook `var'
.
. local isstr = ""
6. local unique = ""
7. local total = ""
8. local class = ""
9.
. local type : type `var'
10. local label : variable label `var'
11.
. local class = "other"
12.
. // test for string
. capture confirm string variable `var'
13. if ( !_rc ) {
14. // we now it is a string
. local isstr = "YES"
15. capture tab `var', matcell( freq )
16. if ( !_rc ) {
17.
. // not too many obs
. local total = `r(N)'
18. local unique = r(r)
19.
. if ( `unique' < `category_cutoff' ) {
20. forvalues i=1/`unique' {
21. if ( `i' == 1 ) {
22. noi di "@freq " _continue
23. }
24. noi di freq[`i',1] _continue
25. if ( `i' == `unique' ) {
26. noi di ""
27. }
28. else {
29. noi di ", " _continue
30. }
31. }
32.
. levelsof `var', local(levels)
33. local i = 1
34. foreach l of local levels {
35. if ( `i' == 1 ) {
36. noi di "@values " _continue
37. }
38. noi di `""`l'""' _continue
39. if ( `i' == `unique' ) {
40. noi di ""
41. }
42. else {
43. noi di ", " _continue
44. }
45. local i = `i' + 1
46. }
47. }
48.
. if ( `total' == 0 ) {
49. local class = "empty"
50. }
51. else if ( `unique' == 1 ) {
52. local class = "constant"
53. }
54. else if ( `unique' == 2 ) {
55. local class = "dummy"
56. }
57. else if ( `unique' < `category_cutoff' & `unique' < `total' ) {
58. local class = "category"
59. }
60. else if (`unique' == `total') {
61. local class = "identifier"
62. }
63. else {
64. local class = "string"
65. }
66. }
67. else {
68. // lots of observations, not sure what to do yet
. // should get random samples here
. noi di "@example0 " `var'[1]
69. }
70. }
71. else {
72. // else assume it is numeric
.
. noi inspect `var'
73.
. local total = r(N)
74. local unique = r(N_unique)
75.
. if ( `unique' < `category_cutoff' ) {
76. local cat = "YES"
77. }
78.
. if ( "`unique'" != "." ) {
79. if ( `total' == 0 ) {
80. local class = "empty"
81. }
82. else if ( `unique' == 1 ) {
83. local class = "constant"
84. }
85. else if ( `unique' == 2 ) {
86. local class = "dummy"
87. }
88. else if ( `unique' < `category_cutoff' & `unique' < `total' ) {
89. capture confirm string variable `var'
90. if ( !_rc ) {
91. local class = "other"
92. }
93. else {
94. local class = "category"
95. }
96. }
97. else if (`r(N_unique)' == `r(N)') {
98. local class = "identifier"
99. }
100. }
101.
. // TODO this takes too long? sum `var', detail
. noi sum `var'
102. local min = r(min)
103. local max = r(max)
104. local nobs = r(N)
105.
. // TODO maybe the precision should be handled later (vm?)
. if ( ( "`type'" != "double" & "`type'" != "float" ) & "`class'" == "constant" ) {
106. noi di "@mean " %9.0f r(mean)
107. }
108. else {
109. noi di "@mean " %9.3f r(mean)
110. }
111. noi di "@sd " %9.3f `r(sd)'
112. // noi di "@skewness " %9.3f `r(skewness)'
. // noi di "@kurtosis " %9.3f `r(kurtosis)'
.
. if ( "`type'" == "double" | "`type'" == "float" ) {
113. noi di "@min " %9.3f `r(min)'
114. noi di "@max " %9.3f `r(max)'
115. // noi di "@p50 " %9.3f `r(p50)'
. }
116. else {
117. noi di "@min " %9.0f `r(min)'
118. noi di "@max " %9.0f `r(max)'
119. // noi di "@p50 " %9.0f `r(p50)'
. }
120. }
121.
.
. if ( ( "`class'" == "constant" ) & ( "`isstr'"!= "YES" ) ) {
122. noi di "@values " `var'[1]
123. }
124. else if ( "`class'" == "category" | "`class'" == "dummy" ) {
125. cap noi {
126. if ( "`isstr'" != "YES" ) {
127. cap tab `var', matcell( freq ) matrow( name )
128. if ( _rc != 0 | ("`r(r)'" != "`unique'") ) {
129. local class = "other"
130. local unique = r(r)
131. }
132. else {
133. forvalues i=1/`unique' {
134. if ( `i' == 1 ) {
135. noi di "@values " _continue
136. }
137. noi di name[`i',1] _continue
138. if ( `i' == `unique' ) {
139. noi di ""
140. }
141. else {
142. noi di ", " _continue
143. }
144. }
145. forvalues i=1/`unique' {
146. if ( `i' == 1 ) {
147. noi di "@names " _continue
148. }
149. local val = name[`i',1]
150. local lab :label (`var') `val'
151. noi di `""`lab'""' _continue
152. if ( `i' == `unique' ) {
153. noi di ""
154. }
155. else {
156. noi di ", " _continue
157. }
158. }
159. forvalues i=1/`unique' {
160. if ( `i' == 1 ) {
161. noi di "@freq " _continue
162. }
163. noi di freq[`i',1] _continue
164. if ( `i' == `unique' ) {
165. noi di ""
166. }
167. else {
168. noi di ", " _continue
169. }
170. }
171. }
172. }
173. }
174. }
175. else {
176. noi di "@example0 " `var'[1]
177. }
178.
. // histogram
. if ( "`isstr'" != "YES" & ("`class'" == "other" | "`class'" == "identifier") ) {
179. cap noi {
180. tempvar h w
181. twoway__histogram_gen `var', gen( `h' `w' )
182. forvalues i=1/`=r(n_x)' {
183. if ( `i' == 1 ) {
184. noi di "@histh " _continue
185. }
186. noi di `h'[`i'] _continue
187. if ( `i' == `=r(n_x)' ) {
188. noi di ""
189. }
190. else {
191. noi di ", " _continue
192. }
193. }
194. forvalues i=1/`=r(n_x)' {
195. if ( `i' == 1 ) {
196. noi di "@histw " _continue
197. }
198. noi di `w'[`i'] _continue
199. if ( `i' == `=r(n_x)' ) {
200. noi di ""
201. }
202. else {
203. noi di ", " _continue
204. }
205. }
206. }
207. }
208.
. noi di "@type `type'"
209. noi di "@label `label'"
210. noi di "@class `class'"
211. noi di "@N_unique `unique'"
212. noi di "@N `total'"
213.
. noi notes `var'
214. }
215.
.
. }
=====spread=====
spread: Number of Observations
--------- ------------------------------
Total Integers Nonintegers
| # Negative - - -
| # # Zero - - -
| # # Positive 3938 35 3903
| # # # ----- ----- -----
| # # # # Total 3938 35 3903
| # # # # # Missing -
+---------------------- -----
.5 1.49 3938
(More than 99 unique values)
Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
spread | 3938 .855772 .2275629 .5 1.49
@mean 0.856
@sd 0.228
@min 0.500
@max 1.490
@example0 1.16
@histh .14364056, .52967459, 1.158102, 2.2802939, 3.4114635, 1.2478775, 2.5316651, 2.0827882, 1.4004955, 1.2658325, 1.6698216, 1.1132144, 1.6877767, 1.5261811, 1.6608441, 1.7236868, 1.2927651, .57456225, .61944997, .42194417, .63740504, .67331517, .52967459, .44887677, .888776, .82593328, .66433764, .38603404, .48478693, .251371, .43989924, .28728113, .23341593, .21546085, .04488768
@histw .51414287, .54242855, .57071429, .59899998, .62728572, .6555714, .68385714, .71214288, .74042857, .76871431, .79699999, .82528573, .85357141, .88185716, .91014284, .93842858, .96671426, .995, 1.0232857, 1.0515715, 1.0798571, 1.1081429, 1.1364286, 1.1647143, 1.193, 1.2212857, 1.2495714, 1.2778572, 1.3061428, 1.3344285, 1.3627143, 1.391, 1.4192858, 1.4475714, 1.4758571
@type float
@label
@class other
@N_unique .
@N 3938
=====rets=====
rets: Number of Observations
------- ------------------------------
Total Integers Nonintegers
| # Negative 1850 - 1850
| # Zero 34 34 -
| # Positive 2054 - 2054
| # ----- ----- -----
| # Total 3938 34 3904
| . . # # . Missing -
+---------------------- -----
-.0687 .0573 3938
(More than 99 unique values)
Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
rets | 3938 .0004028 .0106025 -.0687 .0573
@mean 0.000
@sd 0.011
@min -0.069
@max 0.057
@example0 .0157
@histh .21161334, .14107555, .07053778, .2821511, .2821511, .49376446, .91699111, 1.4812933, 2.8920488, 4.3733425, 8.5350714, 10.086903, 18.76305, 29.696405, 49.517521, 52.621181, 37.385021, 25.11145, 14.037018, 8.4645338, 4.3733425, 3.3858135, 1.6223689, .70537782, .91699111, .63484001, .21161334, .07053778, .21161334, .14107555, .14107555
@histw -.0669, -.0597, -.0489, -.0417, -.0381, -.0345, -.0309, -.0273, -.0237, -.0201, -.0165, -.0129, -.0093, -.0057, -.0021, .0015, .0051, .0087, .0123, .0159, .0195, .0231, .0267, .0303, .0339, .0375, .0411, .0447, .0483, .0519, .0555
@type float
@label
@class other
@N_unique .
@N 3938
.
. // noi profiler report
. // profiler off
.
. exit, clear STATA