HélioThis was my attempt (but results are the expect ones):I now that Jack already gave a better answer.
set seed 732237#Vectorized
scalar T = 100
scalar b1 = -0.2
scalar b2 = 0.5
matrix u = mnormal(T,1)
matrix dx = mnormal(T,1)
matrix dy = zeros(T,1)
matrix y = zeros(T,1)
loop i=2..T -q
dy[i] = b1*y[(i-1)] + b2*dx[i] + u[i]
y[i] = y[i-1] + dy[i]
endloop
set seed 732237
matrix uu = mnormal(T,1)
matrix dxx = mnormal(T,1)
matrix w = zeros(T,1) # same as initial y
result = ( uu = u ) ? "Equal" : "Different"
printf "uu and u matrix are %s\n", result
w[2:T,1] = w[1:(T-1),1] + b1*w[1:(T-1),1] + b2*dxx[2:T,1] + uu[2:T,1]
result = ( w = y ) ? "Equal" : "Different"
print result
matrix z = w ~ y
print z
---On Sat, Mar 29, 2014 at 12:40 PM, Artur T. <artur.tarassow@googlemail.com> wrote:
_______________________________________________<\hansl><hansl>Hello,I was thinking how to implement the following code snippet into a vectorized form, but I couldn't figure out how to do this effectively. The issue I face is the lagged value of y which changes over the loop. Does anybody have an alternative way to run this thing?
scalar T = 100
scalar b1 = -0.2
scalar b2 = 0.5
matrix u = mnormal(T,1)
matrix dx = mnormal(T,1)
matrix dy = zeros(T,1)
matrix y = zeros(T,1)
loop i=2..T -q
dy[i] = b1*y[(i-1)] + b2*dx[i] + u[i]
y[i] = y[i-1] + dy[i]
endloopThanks in advance.
Artur
Gretl-users mailing list
Gretl-users@lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-users
_______________________________________________
Gretl-users mailing list
Gretl-users@lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-users