Page 1 of 1
error message: vector subtracted from scalar
Posted: Sun Jul 21, 2013 12:37 pm
by Lassebn
Hello
I have written the following program in Eviews7:
Code: Select all
!rows = @rows(z_dsf_standard)
vector (!rows) z_HJ_sd
for !i=1 to 3
vector (2) z_r_!i
z_r_!i (1) = z_afkast (!i,1) ' Her fanger jeg ite periodes aktieafkast
z_r_!i (2) = z_afkast (!i,2) ' rf
z_hj_sd (!i) = (z_dsf_standard (!i))^2 - (@inverse(@transpose(z_r_!i)*z_r_!i)*(@transpose(z_r_!i)*(z_dsf_standard (!i)) ))*z_r_!i
next
But when I try to run the program it comes up with an error message saying that I am trying to subtract a vector from a scalar which I can not see that I am doing!!
As you can see z_r_!i is a 2x1 vector and z_dsf_standard is a 130x1 vector but I have picked out the i'th entry of this vector....
Thanks,
Lasse
error message: vector subtracted from scalar
Posted: Sun Jul 21, 2013 1:49 pm
by EViews Gareth
The ith element of a vector is a scalar...
Re: error message: vector subtracted from scalar
Posted: Sun Jul 21, 2013 2:00 pm
by Lassebn
The ith element of a vector is a scalar...
Hey EviewsGareth, thanks for the reply.
Yes i know. I have written
z_dsf_standard (!i))^2 - (@inverse(@transpose(z_r_!i)*z_r_!i)*(@transpose(z_r_!i)*(z_dsf_standard (!i)) ))*z_r_!i
The second term consists of a 1x2 vector * 2x1 vector * 1x2 vector * scalar * 2x1 vector which should result in a scalar, but Eviews says, that I am trying to subtract a vector from a scalar...
Re: error message: vector subtracted from scalar
Posted: Sun Jul 21, 2013 2:08 pm
by EViews Gareth
EViews doesn't know that the result of the matrix algebra is a scalar.
Store the result of that algebra in a temporary vector, then use the 1st element.
Re: error message: vector subtracted from scalar
Posted: Sun Jul 21, 2013 2:19 pm
by Lassebn
Thanks a lot.
Now i have written the following
Code: Select all
!rows = @rows(z_dsf_standard)
vector (!rows) z_HJ_sd
vector (!rows) z_mellemregning
for !i=1 to 3
vector (2) z_r_!i
z_r_!i (1) = z_afkast (!i,1) ' Her fanger jeg ite periodes aktieafkast
z_r_!i (2) = z_afkast (!i,2) ' rf
z_mellemregning (!i) = @inverse(@transpose(z_r_!i)*z_r_!i)*@transpose(z_r_!i)*(z_dsf_standard (!i))*z_r_!i
z_hj_sd (!i) = (z_dsf_standard (!i))^2 - z_mellemregning (!i)
next
but now Eviews says that i am using a nonnumeric argument in the line saying
z_mellemregning (!i) = @inverse(@transpose(z_r_!i)*z_r_!i)*@transpose(z_r_!i)*(z_dsf_standard (!i))*z_r_!i
I can not see what is wrong!!
Re: error message: vector subtracted from scalar
Posted: Sun Jul 21, 2013 3:14 pm
by EViews Gareth
You have an errant space
Re: error message: vector subtracted from scalar
Posted: Mon Jul 22, 2013 2:28 am
by Lassebn
EViews doesn't know that the result of the matrix algebra is a scalar.
Store the result of that algebra in a temporary vector, then use the 1st element.
How do I even calculate the matrix algebra when i can not make the calculations "inside" the vector where I want to store the results?
Bare with me, this is my first attempt at writing a programme

Re: error message: vector subtracted from scalar
Posted: Mon Jul 22, 2013 8:00 am
by EViews Gareth
Code: Select all
matrix temp = @inverse(@transpose(z_r_!i)*z_r_!i)*@transpose(z_r_!i)*(z_dsf_standard (!i))*z_r_!i
!temp2 = temp(1,1)
z_hj_sd (!i) = (z_dsf_standard (!i))^2 - !temp2
Re: error message: vector subtracted from scalar
Posted: Mon Jul 22, 2013 1:47 pm
by Lassebn
Thank you so much for your help and expert knowledge :D