open engel.gdt # set a seed if you want to get same results each time you run this set seed 3213799 # Set the values of the parameters scalar constant = .5 scalar slope = .5 scalar sigma = 1 scalar alpha = .025 # (size of one tail of a 2 sided CI) # Take the natural log of income to use as x genr x = log(income) # start the loop, indicating the desired number of samples. # --progressive is a special command for doing MC simulations (necessary) # --quiet tells gretl not to print all the iterations (highly recommended) loop i=1..400 --progressive --quiet # generate normal errors if i%2 != 0 series u = sigma*normal() else series u = -u endif # generate y genr y = constant + slope*x + u # run the regression ols y const x # save the estimated coefficients genr b1 = $coeff(const) genr b2 = $coeff(x) # save the estimated standard errors genr s1 = $stderr(const) genr s2 = $stderr(x) # generate the lower and upper bounds for the confidence interval genr c1L = b1 - critical(t,$df,alpha)*s1 genr c1R = b1 + critical(t,$df,alpha)*s1 genr c2L = b2 - critical(t,$df,alpha)*s2 genr c2R = b2 + critical(t,$df,alpha)*s2 # count the number of instances when coefficient is inside inverval genr p1 = (constant>c1L && constantc2L && slope