create undated.wf1 u 1 1000 'This program is designed to show that the long run mean of an autoregressive series is the intercept divided by the coefficient of the lagged variable. ' 'First 5 series of 1000 values are generated with an initial value of 4 and coefficients of the lagged variables equal .1, .25, .5, .75 and .9 smpl 1 1 for %1 p10 p25 p50 p75 p90 genr x%1=4 next smpl 2 1000 for %1 %2 p10 .1 p25 .25 p50 .5 p75 .75 p90 .9 genr e=%2*nrnd genr x%1=x%1(-1)*%2+4+e next 'The first 40 observations are plotted to show the convergence to the long run mean values. smpl 1 40 graph mean1.plot xp10 xp25 xp50 xp75 xp90 'The observations are used in 5 regressions to show that the calculation of the long run mean is correct. smpl 1 1000 for %1 p10 p25 p50 p75 p90 equation eq1%1.ls x%1 c x%1(-1) next 'A dummy variable for an intervention is created with a value of 0 for the first 50 periods and 1 thereafter. smpl 1 50 genr Inter=0 smpl 51 1000 genr inter=1 'The data for periods 51 to 1000 are generated again with an intervention of +3 included for %1 %2 p10 .1 p25 .25 p50 .5 p75 .75 p90 .9 genr e=nrnd*%2 genr x%1=x%1(-1)*%2+4+3+e next 'Graphs of the variables are shown to show the approach of the variables to their long run means smpl 1 1000 graph mean2.plot xp10 xp25 xp50 xp75 xp90 'Regressions including the dummy are shown to show how the long run mean is changed. for %1 p10 p25 p50 p75 p90 equation eq2%1.ls x%1 c x%1(-1) inter next