Page 1 of 1
how to concatenate 2 matrix
Posted: Thu Aug 11, 2011 10:43 am
by lisa
good evening,
can any one tell me how to concatenate vertically 2 matrix in eviews?
thanks
Re: how to concatenate 2 matrix
Posted: Thu Aug 11, 2011 10:57 am
by EViews Glenn
Unfortunately, there isn't a single operator for concatenation. :(
Create a new matrix with the appropriate size.
Use matplace to put the two matrices in the appropriate positions.
Code: Select all
matrix(10, 5) a
nrnd(a)
matrix(5, 5) b
nrnd(b)
matrix(@rows(a)+@rows(b), @columns(a)) cc
matplace(cc, a, 1,1)
matplace(cc, b, @rows(a)+1,1)
If you are going to need to do this a lot, we could put together an add-in that would take the two matrices, and a target matrix, and do the concatenation for you.
Re: how to concatenate 2 matrix
Posted: Thu Aug 11, 2011 3:35 pm
by lisa
thanks a lot;
please I have another question,
I want to simulate a VAR(1) model: y(t)=(x(t),z(t))'=A*y(t-1)+u(t)
My problem is how to simulate simultaneously the 2 equations of the model because x depends on z and z depends on x
x=a11*x(-1)+a12*z(-1)+u1
z=a21*x(-1)+a22*z(-1)+u2
(I know how to simulate a model when the variable x depends only on its own lagged values)
Re: how to concatenate 2 matrix
Posted: Fri Aug 12, 2011 10:41 am
by EViews Glenn
To simulate the series you can just use the lags as you've specified, but you'll have to do each element of the matrix multiply separately as you've done. You can't use matrix algebra in the series generation.
(I don't understand the follow reply from seniyajw...)
Re: how to concatenate 2 matrix
Posted: Sun Aug 14, 2011 2:36 am
by lisa
I simulated the elements of the matrix A (a11,a12,a21 and a22) then I typed the model
smpl @all
series x=0
series z=0
genr u1=0.2+0.6*nrnd
genr u2=0.4*(1+nrnd)
smpl @first+1 @last
x=a11*x(-1)+a12*z(-1)+u1
z=a21*x(-1)+a22*z(-1)+u2
my problem is that when I generate the model ((I need 500 observations)), an error message appears (Overflow-Missing data generated) and only 100 observations are generated;
Please how can I get the 500 observations.
Re: how to concatenate 2 matrix
Posted: Sun Aug 14, 2011 7:14 am
by startz
What are the values of a11, etc., in your program?
Re: how to concatenate 2 matrix
Posted: Sun Aug 14, 2011 9:07 am
by lisa
a11,a12 a21 and a22 are random walk process.
a11=a11(-1)+v1
a12=a12(-1)+v2
a21=a21(-1)+v3
a22=a22(-1)+v4
where v1,v2,v3 and v4 are error terms generated as follow:
genr v1=0.6+(1/3)*nrnd
genr v2=0.7+(1/4)*nrnd
genr v3=0.5+0.4*nrnd
genr v4=0.2(1+nrnd)
NB:
I can change the mean and the variance of error terms vi (just I need that the vector v=(v1,v2,v3,v4)' is normally distributed where v1, v2, v3 and v4 are independent.
Re: how to concatenate 2 matrix
Posted: Sun Aug 14, 2011 10:25 am
by startz
Your v terms have a drift, so A grows over time. As a result, x grows very quickly over time. It's possible that it's exploding, although that would surprise me some. Have you looked at a plot of those values of your x variables that are produced to see if they make sense. Finally, what version of EViews are you using and is it up to date?
But bottom line, you seem to be doing everything right. You might post your workfile and see if anyone has a clue.