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

' set workfile range to number of monte carlo replications
workfile mcarlo u 1 100

' create data series for x 
' NOTE: x is fixed in repeated samples
' only first 10 observations are used (remaining 90 obs missing)
series x
x.fill 80, 100, 120, 140, 160, 180, 200, 220, 240, 260

' set true parameter values
!beta1 = 2.5
!beta2 = 0.5

' set seed for random number generator
rndseed 123456

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

' begin loop
for !i = 1 to !reps
	' set sample to estimation sample
	smpl 1 10
 
	' simulate y data (only for 10 obs)
	series y = !beta1 + !beta2*x + 3*nrnd

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

	' set sample to one observation
	smpl !i !i

	' and store each coefficient estimate in a series
	series b1 = eq1.@coefs(1)
	series b2 = eq1.@coefs(2)
next
' end of loop

' set sample to full sample
smpl 1 100

' show kernel density estimate for each coef
freeze(gra1) b1.kdensity
' draw vertical dashline at true parameter value
gra1.draw(dashline, bottom, rgb(156,156,156)) !beta1
show gra1

freeze(gra2) b2.kdensity
' draw vertical dashline at true parameter value
gra2.draw(dashline, bottom, rgb(156,156,156)) !beta2
show gra2
