## Possible Bug in Model Simulation

For notifying us of what you believe are bugs or errors in EViews.

Moderators: EViews Gareth, EViews Moderator

Dennis
Posts: 16
Joined: Fri Dec 16, 2011 8:11 am

### Possible Bug in Model Simulation

When doing stochastic simulation in a model, I find that the confidence bounds are too wide. Here are two examples:

If I simulate from the uniform distribution using the following:
r1=rnd
I obtain 90% confidence bounds that are outside of the support of the distribution. The simulated bounds are approximately -.32 and 1.32.

If I simulate from the standard normal distribution using
r2=nrnd
I obtain 90% confidence bounds that are too wide, approximately -2.9 and +2.9

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 11776
Joined: Tue Sep 16, 2008 5:38 pm

### Re: Possible Bug in Model Simulation

I think you're forgetting to include the innovations in your interpretation of what the bounds should be.

Dennis
Posts: 16
Joined: Fri Dec 16, 2011 8:11 am

### Re: Possible Bug in Model Simulation

Could you elaborate Gareth. I've read the discussion of simulation in the help file and may not be understanding how the simulation works. I thought the simulation of r1=rnd in a model object would draw 1,000 observations from the [0,1] uniform distribution and then compute the confidence bounds from that simulation. (By the way, if it matters, I'm using Stochastic Static simulation.) Thanks.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 11776
Joined: Tue Sep 16, 2008 5:38 pm

### Re: Possible Bug in Model Simulation

Each equation in the model, unless it is specified as an identity, has an implicit error term on the end. So your line:

Code: Select all

`r1 = rnd`

is actually:

Code: Select all

`r1 = rnd + nrnd`

where the stochastic solve is generating the nrnd part.

Dennis
Posts: 16
Joined: Fri Dec 16, 2011 8:11 am

### Re: Possible Bug in Model Simulation

I understand. Is there a workaround? If I use
@identity r1=rnd
I get an error message: "Matrix or vector given non positive dimension"

It may help if I provide more background. In an earlier post on simulating from a discrete distribution, a contributor named Glenn responded to my post and suggested the following two lines of code to simulate from a discrete distribution. I thought this was an appealing way to proceed but, when I implemented it, I found that this did not produce the correct discrete distribution. I now understand why, but I am not sure how to get around this problem.

z = rnd
@identity w = 8 * (z<.2) + 10 * (z<.3 and z>=.2) + 15 * (z<.55 and z>=.3) + 17 * (z<.72 and z>=.55) + 22 * (z>=.72)

EViews Glenn
EViews Developer
Posts: 2590
Joined: Wed Oct 15, 2008 9:17 am

### Re: Possible Bug in Model Simulation

Ah, sorry, it's the extra nrnd at the end of the Z which I didn't think about. Let us think about this for a bit.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 11776
Joined: Tue Sep 16, 2008 5:38 pm

### Re: Possible Bug in Model Simulation

Try using:

Code: Select all

`m.stochastic(m=1e-16)`

which should multiply the innovation covariance matrix by (essentially) zero, meaning the innovations become tiny.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 11776
Joined: Tue Sep 16, 2008 5:38 pm

### Re: Possible Bug in Model Simulation

Glenn pointed out another trick that is slightly better:

Code: Select all

`model mm.append r2=0m.append @innov r2 1m.append @identity r1 = @cnorm(r2)m.solve(s=a)`

r2 gets generated with a variance of 1 from the normal. The cnorm of a normal returns a uniform.

EViews Glenn
EViews Developer
Posts: 2590
Joined: Wed Oct 15, 2008 9:17 am

### Re: Possible Bug in Model Simulation

Note that the R1 in Gareth's snippet gives you the Z from above which you'll feed into the other identity.

Code: Select all

`@identity w = 8 * (z<.2) + 10 * (z<.3 and z>=.2) + 15 * (z<.55 and z>=.3) + 17 * (z<.72 and z>=.55) + 22 * (z>=.72)`

Dennis
Posts: 16
Joined: Fri Dec 16, 2011 8:11 am

### Re: Possible Bug in Model Simulation

Thank you both. I really appreciate the help!