# demonstrate the effect of E(u|X) not equal to 0 set verbose off # create an artificial dataset with 200 observations nulldata 200 # uniform() generates a uniformly distributed r.v. series x = 20 * uniform() K = 5000 matrix slope = zeros(K,1) loop i=1..K --quiet # the error term, u, is "purely random" series u = normal() series y = 10 + 1.5*x + u ols y 0 x --quiet slope[i] = $coeff[2] endloop # meanc() gives the column mean(s) for a matrix printf "unbiased: mean slope = %g\n", meanc(slope) loop i=1..K --quiet # the error term will be correlated with x series u = 0.2*x + normal() series y = 10 + 1.5*x + u ols y 0 x --quiet slope[i] = $coeff[2] endloop printf "biased: mean slope = %g\n", meanc(slope)