simple bootstrap

For questions regarding programming in the EViews programming language.

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

cel
Posts: 35
Joined: Fri Jan 20, 2012 7:39 am

simple bootstrap

Postby cel » Mon Nov 19, 2012 7:26 am

I've been trying to generate a time series y from an eqn like
y(t)=a+b*X(t) + res(t)
giving a looping randominzed parameter support for a, b and the residual. Thus, i monte carlo not just the error but also the conefficients. I get the message (too many random innovations). See below. Any help much appreciated.
________________
' set seed for random number generator
rndseed 123456

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

!time=43 'length of sample

vector(!time) tech_m

'generate the series
'general form y=(a/b)*(x1-const-c*x2-error)
series tech = ((0.1+(5-0.1)*rnd)/((0.1+(5-0.1)*rnd)-1))*(lcp - 0+(0.5-0)*rnd + (1/(0.1+(5-0.1)*rnd))*log(nsnu) - (0.05*nrnd))*(1/(0+(0.05-0)*rnd))

for !t = 1 to 43 'the full sample is 1963-2005
smpl 1963 1963+!time

for !i = 1 to !reps

tech.resample tech_b

'generate the mean of the series over each incremental time point
tech_m(!t) = @mean(tech_b)

next
next

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

Re: simple bootstrap

Postby EViews Gareth » Mon Nov 19, 2012 8:47 am

Too many RND and NRND terms in your series command. Pre-generate some of the random terms into other series first:

Code: Select all

series temp = rnd series tech = ((0.1+(5-0.1)*temp)....

cel
Posts: 35
Joined: Fri Jan 20, 2012 7:39 am

Re: simple bootstrap [retreive original series]

Postby cel » Mon Nov 19, 2012 3:20 pm

Many thanks. Can i pursue one follow up?

Just for fun, I did a simple regression of a vble LCP, then did a Monte Carlo using the parameter variability in that estimation to see if I retreived something like the LCP original series. Turns out I didn't. Am I making some silly mistake or misuing an eviews function? Many thanks in advance.
----
' Dependent Variable: LCP
' Method: Least Squares
' Sample (adjusted): 1963 2005
' Included observations: 43 after adjustments
'
' Variable Coefficient Std. Error t-Statistic Prob.
'
' C 0.110158 0.033012 3.336892 0.0018
' TT 0.018005 0.001491 12.07680 0.0000
' LOG(NSNU) -0.389809 0.048405 -8.053153 0.0000
'......
' S.E. of regression 0.024571

!cu=0.176024 ' ==.11+2*0.033012=0.176024 etc, upper limit
!cl=0.043976 ' ==.11-2*0.033012=0.043976 etc, lower limit

!ttu=0.020987
!ttl=0.015023

!nl=-0.292999
!nu= -0.486619

' set seed for random number generator
rndseed 123456

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

!time = 43

vector(!time) lcp_mc_median

'generate the series
series temp1 = rnd
series temp2 = nrnd
'series lcp_mc = !cl+(!cu-!cl)*temp + (!ttl+(!ttu-!ttl)*temp)*tt + (!nl+(!nu-!nl)*temp)*log(nsnu) + 0.024571*nrnd 'first attempt
'series lcp_mc = 0.110158*0.033012*temp1 + (0.018+0.001491*temp1)*tt - (0.389809+0.048*temp1)*log(nsnu) + 0.024571*nrnd 'second attempt
series lcp_mc = 0.110158*0.033012*temp2 + (0.018+0.001491*temp2)*tt - (0.389809+0.048*temp2)*log(nsnu) + 0.024571*nrnd 'current attempt

for !t = 1 to 43 'sample = 1963-2005
smpl 1963 1963+!t-1

for !i = 1 to !reps

lcp_mc.resample lcp_mc_b

next
lcp_mc_median(!t) = @median(lcp_mc_b)
next

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

Re: simple bootstrap

Postby EViews Gareth » Mon Nov 19, 2012 3:23 pm

That's an econometrics issue.

cel
Posts: 35
Joined: Fri Jan 20, 2012 7:39 am

Re: simple bootstrap

Postby cel » Tue Nov 20, 2012 6:04 am

Well, I didnt intend it to be an econometrics issue.

More in fact as to whether i used the loop and declared the matrices correctly.

The idea is simply to do a regression, then try to get the dependent variable back by doing on a Monte Carlo exploiting the parameters and their SEs in the first stage.

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

Re: simple bootstrap

Postby EViews Gareth » Tue Nov 20, 2012 8:43 am

I see nothing immediately wrong with your coding.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests