Pick random number from a series

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

vishaleviews
Posts: 8
Joined: Mon Oct 07, 2013 8:56 am

Pick random number from a series

Postby vishaleviews » Mon Oct 07, 2013 9:00 am

hi,

i have run an equation and stored the residuals in a series. now i want to pick random number from this series. how can i do this. thanks..

p.s.: i know this is a very basic question. new to eviews and stats so my questions might be very basic..

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

Re: Pick random number from a series

Postby EViews Gareth » Mon Oct 07, 2013 9:14 am

Proc->Resample

vishaleviews
Posts: 8
Joined: Mon Oct 07, 2013 8:56 am

Re: Pick random number from a series

Postby vishaleviews » Mon Oct 07, 2013 11:00 pm

thanks Gareth..

I want to just pick one random number from the series and i want to do this using program.

One more help, it its not too much..

My overall objective is to run a simulation (bunch of simulation/stochastic simulation) - my system of equation is

dusd = c2*dusd(-1) + c3*dgbp(-1) +c4*(gdp(-1)-usd(-1)-c1)
dgbp = c5*dgbp(-1) + c6*dusd(-1) +c7*(gdp(-1)-usd(-1)-c1)

where dusd = usd- usd(-1)

but i cannot use forecast command with such equations. so i want to use for loop or any other method to run this equation and add the dusd value to usd to get usd(t) and run the equation again; repeat this for some horizon (lets say one year i.e., from 9/27/2013 to 9/26/2014) . And then repeat the whole process to get stochastic simulations (lets say 1000). i want to use the random residual value to add to above equations. Once i have the simulations, i can then see the distribution of the level of rates at each point over the forecast horizon.

attaching the data file and the program..

can you please help me with this. thank a lot..
Attachments
Simulation.xlsx
(41.73 KiB) Downloaded 317 times

vishaleviews
Posts: 8
Joined: Mon Oct 07, 2013 8:56 am

Re: Pick random number from a series

Postby vishaleviews » Mon Oct 07, 2013 11:01 pm

also including the program here

'Import data from excel file

import "simulation.xlsx"

'Create first difference series
series dusd = usd - usd(-1)
series dgbp = gbp - gbp(-1)

'Include all data points
smpl 1/15/1999 @last

'Equations
equation r1.ls DUSD = C(2)*DUSD(-1)+C(3)*DGBP(-1)+C(4)*(GBP(-1)-USD(-1)-C(1))
equation r2.ls DGBP = C(5)*DGBP(-1)+C(6)*DUSD(-1)+C(7)*(GBP(-1)-USD(-1)-C(1))

system sys01
sys01.append DUSD = C(2)*DUSD(-1)+C(3)*DGBP(-1)+C(4)*(GBP(-1)-USD(-1)-C(1))
sys01.append DGBP = C(5)*DGBP(-1)+C(6)*DUSD(-1)+C(7)*(GBP(-1)-USD(-1)-C(1))
sys01.sur(deriv=aa)

vishaleviews
Posts: 8
Joined: Mon Oct 07, 2013 8:56 am

Re: Pick random number from a series

Postby vishaleviews » Tue Oct 08, 2013 6:17 am

if the second part is too much to work on, please ignore it.

it would be great if you could help me with just the program to draw a random number (only one number) from a series. thanks much..

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

Re: Pick random number from a series

Postby EViews Gareth » Tue Oct 08, 2013 7:47 am

Silly question, but it seems to me that what you are doing is exactly what a stochastic solve of a model does. Why not just put your system into a model, and perform a stochastic solve?

vishaleviews
Posts: 8
Joined: Mon Oct 07, 2013 8:56 am

Re: Pick random number from a series

Postby vishaleviews » Tue Oct 08, 2013 9:02 am

silly i'm :-) yes i'm trying to do exactly that but as i mentioned earlier, i cant use solve here because the equation will not allow me to.. it says unable to compute due to missing data. i want to solve this for future period for which rates are not available and hence it cant be solved. let me know if this is not correct. did you try solving the below equation using model.solve?

i have written a program for that but its taking considerable time (~15 mins or so) for 1000 iterations. i think its because i have created group and adding 1000 items to the group. I'm doing this to plot the distribution of those 1000 iterations. Is there a simpler method to do this?

can you help me with the code to draw a random number from a series.

thanks for your patience..

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

Re: Pick random number from a series

Postby EViews Gareth » Tue Oct 08, 2013 9:11 am

I'm afraid I don't follow what you're doing.

vishaleviews
Posts: 8
Joined: Mon Oct 07, 2013 8:56 am

Re: Pick random number from a series

Postby vishaleviews » Tue Oct 08, 2013 9:30 am

oh my bad. I have just one question.

1) can you help me with the code to draw a random number from a series

On your suggestion that i could have just used Model and Solved it for simulation, I don't think the equation can be solved using that (I had earlier attached the data file and program). You can give it a try. I don't think it works. For that reason, i have written a program. Let me know if it can be solved using Model and Solve.

thanks..


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests