Monte Carlo for Censored varriable

For questions regarding programming in the EViews programming language.

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

saali5984
Posts: 5
Joined: Sat Dec 19, 2009 4:20 am

Monte Carlo for Censored varriable

Postby saali5984 » Sat Dec 19, 2009 5:02 am

Hello
How I can write a Monte Carlo experiment for the following problem?????

Ysi=a+b*Xi+e

Create N = 200 random values of xi that are spread evenly (or uniformly) over the interval [0, 20]. These we will keep fixed in further simulations.
Obtain N = 200 random values ei from a normal distribution with mean 0 and variance 16.
Create N = 200 values of the latent variable. (Ysi)
Obtain N = 200 values of the observed yi using
Yi=0 if Ysi<=0
Yi=Ysi if Ysi>0
then estimate
Ysi=a+b*Xi+e
Yi=c+d*Xi+e
and save the vector of estimated coefficiants of equations written in above. In AandB vectores.

startz
Non-normality and collinearity are NOT problems!
Posts: 3797
Joined: Wed Sep 17, 2008 2:25 pm

Re: Monte Carlo for Censored varriable

Postby startz » Sat Dec 19, 2009 8:51 am

When you post a homework question, it's best to show what you've done so far so people can figure out how to give you a helpful hint.

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

Re: Monte Carlo for Censored varriable

Postby EViews Gareth » Sat Dec 19, 2009 8:58 am

Pretty simple for loop:

Code: Select all

!its = 100 !t = 200 create u !t matrix(2,!its) res1 matrix(2,!its) res2 series ei series yi series ysi equation e1 equation e2 series xi = rnd*20 for !i=1 to !its ei = 4*nrnd ysi=xi+ei yi = @recode(ysi<0,0,ysi) e1.ls ysi c xi e2.ls yi c xi colplace(res1,e1.@coefs,!i) colplace(res2,e2.@coefs,!i) next


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest