? Program SIMTUT.LIM begun Oct 14 1996. ? To run in batch mode .. Limdep simtut.lim simtut.out ? This is for a Poisson simulation. Easily changed to other simulations. ? The model is Y ~ Poisson with mean exp(1+2X) where X ~ N(0,1) TITLE; ****** Poisson Simulation Example $ ?******** OUTPUT OPEN; OUTPUT = SIMTUT.OUT $ ?******** READ IN DATA, CREATE VARIABLES AND GIVE SUMMARY STATISTICS ? There is no data to read in. ? Instead draw a Tx1 vector of regressors from the normal. ? Set sample size CALC; nobserv = 10 $ SAMPLE; 1-nobserv $ ? Set random number generator seed to allow replication CALC; Ran(6710671) $ ? Regressor X is a draw from N(0,1) CREATE; X = RNN(0,1) $ DSTAT; rhs = X $ ?******** INITIALIZE MATRICES etc. FOR SIMULATIONS CALC; nsims=20; nregress=2 $ ? ** Initialize matrices ? Because later on I want to convert matrices to variables using ? create, store result as column vector rather than row ? Simulation results are s x k or nsims x nregress MATRIX; bpoiss=init(nsims,nregress,0) $ ? Counter for simulations CALC; isim=1 $ ? Suppress output FAST $ SILENT $ ?******** BEGIN SIMULATIONS ? Do this differently if interactive procedure CREATE; MU = exp(1+2*X); Y = RNP(MU) $ POISSON; LHS=Y; RHS=ONE,X $ MATRIX; bpoiss(isim,*)=b $ CALC; isim=isim+1 $ endprocedure exec; silent; n=nsims $? ?******* REPORT SIMULATION RESULTS ? Create separate vectors for each regressor matrix; bone=Part(bpoiss,1,nsims,1,1); bx=Part(bpoiss,1,nsims,2,2) $ matrix; dsta(bone,bx) $ ?matrix; list; bx $ TITLE; ****** Simulation histograms of estimated coefficients $ ? Need to transform row vector matrices to column of variables sample; 1-nsims $ create; simbone = bone $ create; simbx = bx $ dstat; rhs = simbone,simbx; quantiles $ hist; rhs = simbx; limits=1.7,2.3; int=30 $ For n=10 STOP $