' store monte carlo results in a matrix
' for version 4
' last checked 11/2/2000 h

' set workfile range to number of obs
workfile mcarlo u 1 10

' create data series for x 
' NOTE: x is fixed in repeated samples
series x
x.fill 80, 100, 120, 140, 160, 180, 200, 220, 240, 260

' set seed for random number generator
rndseed 123456

' assign number of replications to a control variable
!reps = 100

' declare storage matrix 
matrix(!reps,2) beta

' begin loop
for !i = 1 to !reps 
	' simulate y data
	series y = 2.5 + 0.5*x + 3*nrnd

	' regress y on a constant and x
	equation eq1.ls y c x

	' store each coefficient estimate in matrix
	beta(!i,1) = eq1.@coefs(1)	' column 1 is intercept
	beta(!i,2) = eq1.@coefs(2)	' column 2 is slope
next
' end of loop

' show descriptive stats of coef distribution
beta.stats
