* * Graph examples from page 19 * calendar(m) 1926:1 * * The IBM data are simple returns. * open data ch01_ibmvwewsp_m(26-03).txt data(format=free,org=columns) 1926:1 2003:12 date ibmsmp set ibmlog = log(ibmsmp+1) * * Scale returns up to percentages * set ibmsmp = 100*ibmsmp set ibmlog = 100*ibmlog * * This uses SPGRAPH to create a graph with two horizontal panes. Note that the * appearance of the empirical densities depends upon the choice of bandwidth and * window type, and also upon the coarseness of the grid of "x" values at which the * density is computed. The default bandwidth in the DENSITY instruction appears to * be a bit narrower than the one used in Figure 1.4, and the grid used here is a * bit finer, leading to more rounded features. (The RATS graph of the density * will also be a set of line segments, but they will be shorter, with more * frequent slope changes, and thus will look more like a curve). * spgraph(hfields=2,footer="Figure 1.4 Comparison of Empirical and Normal Densities for IBM Stock Returns") stats ibmsmp density ibmsmp / xgrid fsmp set nsmp = 1.0/sqrt(%variance)*%density((xgrid-%mean)/sqrt(%variance)) scatter(style=lines,hlabel="simple-rtn",vlabel="density") 2 # xgrid fsmp # xgrid nsmp * density ibmlog / xgrid flog set nlog = 1.0/sqrt(%variance)*%density((xgrid-%mean)/sqrt(%variance)) scatter(style=lines,hlabel="log-rtn",vlabel="density") 2 # xgrid flog # xgrid nlog spgraph(done)