clear capture log close log using spurious.txt, text replace di "spurious.txt: stata simulation example for spurious regression" version 7 *Example of random walk: Y_t = Y_(t-1) + u_t *y_0 = 0, u_t ~ iid N(0,1) drop _all set obs 100 gen u = invnorm(uniform()) gen v = invnorm(uniform()) * y_t is a cumulative sum gen y = sum(u) gen x = sum(v) range time 1 100 100 tsset time regress y x predict yhat, xb twoway (scatter y x) (line yhat x) capture log close