Page 1 of 1

Useful class demonstration program

Posted: Wed Aug 28, 2013 9:26 am
by startz
Here's a little program I wrote to show the Monte Carlo distribution of an estimator. What's neat about doing this in EViews is that students get to see the histogram change dynamically as the simulations are done and then see the distribution settle down as the number of simulations grows.

Code: Select all

'meanSim.prg
'simulate sample mean
'Dick Startz
'August 2013
!sampleSize =1000
!trials = 1000 'must be greater than or equal to sample size
!mu = 12
!sigma = 2.85
workfile tryit u !trials
vector (!trials) muHat = na

smpl 1 !sampleSize
for !i=1 to !trials
series y = !mu + !sigma*nrnd ' substitute whatever DGP you want
muHat (!i) = @mean(y) ' substitute whatever estimator you want
muHat.distplot
next