error message: vector subtracted from scalar

For questions regarding programming in the EViews programming language.

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

Lassebn
Posts: 14
Joined: Fri May 10, 2013 12:29 am

error message: vector subtracted from scalar

Postby Lassebn » Sun Jul 21, 2013 12:37 pm

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

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

error message: vector subtracted from scalar

Postby EViews Gareth » Sun Jul 21, 2013 1:49 pm

The ith element of a vector is a scalar...

Lassebn
Posts: 14
Joined: Fri May 10, 2013 12:29 am

Re: error message: vector subtracted from scalar

Postby Lassebn » Sun Jul 21, 2013 2:00 pm

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...

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

Re: error message: vector subtracted from scalar

Postby EViews Gareth » Sun Jul 21, 2013 2:08 pm

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.

Lassebn
Posts: 14
Joined: Fri May 10, 2013 12:29 am

Re: error message: vector subtracted from scalar

Postby Lassebn » Sun Jul 21, 2013 2:19 pm

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!!

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

Re: error message: vector subtracted from scalar

Postby EViews Gareth » Sun Jul 21, 2013 3:14 pm

You have an errant space

Lassebn
Posts: 14
Joined: Fri May 10, 2013 12:29 am

Re: error message: vector subtracted from scalar

Postby Lassebn » Mon Jul 22, 2013 2:28 am

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 :oops:

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

Re: error message: vector subtracted from scalar

Postby EViews Gareth » Mon Jul 22, 2013 8:00 am

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

Lassebn
Posts: 14
Joined: Fri May 10, 2013 12:29 am

Re: error message: vector subtracted from scalar

Postby Lassebn » Mon Jul 22, 2013 1:47 pm

Thank you so much for your help and expert knowledge :D


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests