** Chapter 4.3 ** for W.H. Greene, Econometric Analysis 6th ed. ***************** * (c) Noel Roy 2003, 2008 * * UNBIASED ESTIMATION * The Sampling Distribution of a Least Squares Estimator * * The tutorial for this section will review the following tasks in SHAZAM: * • Performing repeat operations (DO command) * • Setting dimensions of arrays (DIM command) * • Generating constants (GEN1 command) * • Generating normally distributed variables (NOR function) * • Storing OLS coefficients in a vector (OLS/COEF=) * • Plotting graphs and histograms (GRAPH and PLOT commands) * *=============================================================================== * * 4.3 UNBIASED ESTIMATION * * Example 4.1 (p. 47) The Sampling Distribution of a Least Squares Estimator * * The histogram in Figure 4.1 is generated by running 500 regressions, * storing the value of the least square slope after each regression. * First, DIMension the variable B in which the slope estimates are to be * stored. This is necessary because the variable B is created * sequentially, and it is necessary to reserve space for it. * DIM B 500 * * SHAZAM can perform repeated operations through the use of the DO command. * SHAZAM will perform all the commands between a DO statement and an ENDO * statement, for all values of a so-called DO-variable over a specified range. * The DO variable must be a symbol such as #, %, !, or ?. * * First, generate a sample of 100 random draws from a standard normal * population on both w and x. * SAMPLE 1 100 * * Commands are usually printed for each cycle in a SHAZAM DO-loop. With 500 repeats, * this can result in a voluminous amount of (mostly useless) output. The * SET NODOECHO command suppresses this output. * SET NODOECHO DO #=1,500 * * The NOR(x) function used with the GENR command generates normally * distributed random numbers with standard deviation x. * GENR W=NOR(1) GENR X=NOR(1) GENR e=0.5*W GENR Y=0.5+0.5*X+e * * Now do an OLS regression of Y on X, and save the estimates in the vector C. * This is done through the COEF= option. The OLS command is preceded by a * ?, in order to suppress the output we would normally get from this command * (since all we need to do is to save the value of the estimate of the slope). * ?OLS Y X /COEF=C * * The vector C has two elements, the estimate of the slope and the * estimate of the constant. The former is denoted by C(1). We want * to save this in the B vector. We do this using the GEN1 command. This * command is like the GENR command, but generates a constant rather than a * series. * GEN1 B(#)=C(1) * * C(1) is stored in the #th element of B. * These commands are performed 500 times, once for each value of # between 1 and * 500. * ENDO * * Now plot the 500 estimates of the slope term as a histogram. This is done * by the GRAPH command with the HISTO option. * When the HISTO option is used, the data is normally placed into six groups. * The GROUPS= option over-rides this default. The values available for the * GROUPS= option are 2,3,4,5,6,10,12,15,30, or 60. * SAMPLE 1 500 GRAPH B / HISTO GROUPS=30 STOP * *=============================================================================== * * Updated August 27, 2008