Page 1 of 1

matlab to eviews

Posted: Wed Mar 14, 2012 9:01 pm
by cyp74
Hi,
I am trying to replicate a matlab code in EViews but having trouble doing the following loop;

for jj=1:nstep;
impz(jj,:)=shock(jj,:)+zlag*betaz(1:length(betaz),:);
zlag=[impz(jj,:) zlag(1,1:(nlags-1)*nvars)];
end;

I've managed to convert lots of stuff but having trouble with this kinda looping and concatenation. Could anyone please help me with this? Thanks

C.

Re: matlab to eviews

Posted: Wed Mar 14, 2012 11:46 pm
by cyp74
Can anyone respond please?

Re: matlab to eviews

Posted: Fri Mar 16, 2012 12:18 am
by trubador
Could you please at least tell us the dimensions of matrices/vectors you are dealing with?

Re: matlab to eviews

Posted: Fri Mar 16, 2012 12:38 am
by cyp74
Thanks for your reply Trubador,
impz=15*7
shock=15*7
zlag=1*28
betaz=28*7
nlags=4
nvars=7

Hope it helps

C.

Re: matlab to eviews

Posted: Sat Mar 17, 2012 7:27 am
by trubador
This should be doing what you want:

Code: Select all

!nvars = @columns(shock) !nstep = @rows(shock) !nlags = 4 !extract = (!nlags-1)*!nvars rowvector temp1 rowvector temp2 for !jj = 1 to !nstep temp1 = @rowextract(shock,!jj)+zlag*betaz temp2 = @subextract(zlag,1,1,1,!extract) rowplace(impz,temp1,!jj) matplace(zlag,temp1,1,1) matplace(zlag,temp2,1,!nvars+1) next delete temp*

Re: matlab to eviews

Posted: Sun Mar 18, 2012 12:23 am
by cyp74
Trubador, that's awesome. Many thanks