* * Section 2.5.2 * Figure 2.9, p. 60 and Figure 2.10, p. 61 * Figure 2.10, note: the explosive series has wrong dgp * all 500 * * We'll generate the three series using a common "u" series, so the differences * will be due solely to their different coefficients. Note that these series * won't match the ones shown in the text, because the random numbers chosen won't * match. In fact, you'll get different series every time you run this, since the * random number generator in RATS is "seeded" based upon the time of day the * program starts running. If you want to control the set of numbers so you can * reproduce output, use the SEED instruction. The syntax for that is SEED big * integer, like SEED 43403. * * The %ran(x) function returns a Normal draw with mean 0 and standard deviation x. * set u = %ran(1.0) * * The FIRST option on SET is helpful in sitations like this where the first * observation is generated differently than the remaining ones. * set(first=0.0) a = .05+ .95*a{1}+u set(first=0.0) r = .05+1.00*r{1}+u set(first=0.0) e = .05+1.05*e{1}+u graph(key=below,footer="Figure 2.9 A stationary AR(1) series and a random walk") 2 # a # r * * The explosive series shown in the text doesn't look representative of the * process; the order of magnitude at the end of the sample should be more like * 10 to the 10th or 11th power. The sign isn't even determined; they could be * very large positive or very large negative-this all depends upon the signs of * the first few u's. * graph(key=below,footer="Figure 2.10 An explosive series") 3 # a # r # e * * Generate table on page 61. The autocorrelations are computed with the * instruction CORRELATE. As described on page 61, these are computed using * the data from observations 101 to 500. The autocorrelations for "a" are * put into series "ca" and for "r" are "cr". Note that the first entry in * ca actually is the 0 lag autocorrelation, that is, 1. So in the REPORT * instructions below, to get the correlation for lag i, we need ca(i+1) and * cr(i+1). * correlate(number=50,corrs=ca,noprint) a 101 500 correlate(number=50,corrs=cr,noprint) r 101 500 * * Same thing, using the REPORT instruction * report(action=define,hlabels=||"Lag","A series","R series"||) dofor i = 1 5 9 13 18 report(row=new,atcol=1) i ca(i+1) cr(i+1) end dofor report(action=format,picture="#.###") report(action=show,window="Table 2.3") * * Not expressed in the book, but described on pp. 60-1 * graph(key=loleft,footer="Autocorrelations values for A and R series") 2 # ca # cr * * Example of what is said on pp. 62-3 about LS and ML estimates of the linear model * * Linear regression * set y = a set x = r linreg(noprint) y # constant x display @11 "b_0" @26 "b_1" @41 "Var" display @5 %beta(1) @20 %beta(2) @35 %seesq * * Same thing, using ML * nonlin b_0 b_1 var frml error = y - b_0 - b_1*x frml L = %logdensity(var,error) * * LINREG is used to get guess values * linreg(noprint) y # constant x compute b_0 = %beta(1), b_1 = %beta(2), var = %seesq maximize(method=bhhh) L