' PROGRAM FOR EXAMPLE 1: THE T-TEST WHEN THE REGRESSION MODEL'S ERRORS ARE HIGHLY NON-NORMAL 'First, initialize some quantities: rndseed 12345 !n=10 ' Sample size !nrep=10000 ' Number of Monte Carlo replications smpl 1 !n scalar b0=1 scalar b1=0 ' H0 is TRUE for the t-test. We're going to conduct ONE-SIDED t-tests scalar crit10 = @qnorm(0.90) ' This is the 10% critical value for a 1-sided test assuming (asymptotic) Normality scalar crit05 = @qnorm(0.95) ' This is the 5% critical value for a 1-sided test assuming (asymptotic) Normality scalar crit01 = @qnorm(0.99) ' This is the 1% critical value for a 1-sided test assuming (asymptotic) Normality ' These are just for comparative purposes series error series y vector(!nrep) t for !i = 1 to !nrep ' Now start the Monte Carlo loop error=@runif(0,1) ' The errors are Uniform [0 , 1] y=b0+b1*x1+error ' Generate the random Y data equation eq1.ls y c x1 t(!i)=@tstats(2) ' Save the t-statistic for testing H0: b2 = 0 next ' End of the Monte Carlo loop smpl 1 !nrep vector tv=@sort(t , "a" , "f") scalar crit10_actual=tv(9000) ' Compute the "actual" finite-sample critical values from the ranked t-statistics show crit10_actual scalar crit05_actual=tv(9500) show crit05_actual scalar crit01_actual=tv(9900) show crit01_actual mtos(tv , ts) ' Convert the VECTOR of saved t-statistics into a SERIES to facilitate plotting, etc. '(can convert either tv or t here) series idum=@obsnum ' Now compute actual "sizes" of the test if asymptotic crit. vals. were wrongly used smpl 1 !nrep if ts> crit01 ' This will give us measures of "size distortion" due to small sample size scalar size01=(@last(idum)-@first(idum)+1)/!nrep show size01 smpl 1 !nrep if ts> crit05 scalar size05=(@last(idum)-@first(idum)+1)/!nrep show size05 smpl 1 !nrep if ts> crit10 scalar size10=(@last(idum)-@first(idum)+1)/!nrep show size10 smpl 1 !nrep show ts hist ts ' Display the results for the complete sampling distribution of our test statistic