Matrix with NAs

For questions regarding programming in the EViews programming language.

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

ral
Posts: 23
Joined: Tue Oct 21, 2014 2:44 pm

Matrix with NAs

Postby ral » Fri Feb 19, 2016 11:58 am

Hi,

I would like to produce a TxN matrix from a set of N individual series. The issue is that there are time periods with NAs in each of the series. I want to keep track of the NAs in the matrix.

To solve the problem, I tried two possibilities (below), but neither worked. The output is a TxN matrix pricesmat. The individual series with the NAs are stored as subcomp{!j}_pc, where j=1,...,N indexes each individual series.

Thank you.

ATTEMPT 1. Error is 'Pricesmat(T,1) is an illegal or reserved name'
matrix(T,N) pricesmat = @zeros(T,N)
for !j = 1 to N
stomna(subcomp{!j}_pc,pricesmat(T,!j))
next

ATTEMPT 2. Error is 'Nonumeric argument in subcomp1_v'
matrix(T,N) pricesmat = @zeros(T,N)
for !j = 1 to N
vector(T) subcomp{!j}_v
stomna(subcomp{!j}_pc,subcomp{!j}_v)
pricesmat(T,!j) = subcomp{!j}_v
next

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

Re: Matrix with NAs

Postby EViews Gareth » Fri Feb 19, 2016 12:14 pm

Attempt 2 is the way to go.

I'm not sure what

Code: Select all

pricesmat(T,!j) = subcomp{!j}_v

is meant to be doing, but you probably want to use the colplace function.
Follow us on Twitter @IHSEViews

ral
Posts: 23
Joined: Tue Oct 21, 2014 2:44 pm

Re: Matrix with NAs

Postby ral » Fri Feb 19, 2016 12:29 pm

Thanks, Gareth. This line

pricesmat(T,!j) = subcomp{!j}_v

was supposed to replace each of the j=1,...,N columns with the j=1,...,N series, but that appears to be the source of the error.

After I sent the email, I remembered the colplace command and modified the loop, but I still get an error message. Here is the modified loop:

matrix(T,N) pricesmat = @zeros(T,N)
for !j = 1 to N
vector(T) subcomp{!j}_v
stomna(subcomp{!j}_pc,subcomp{!j}_v)
colplace(pricesmat(T,!j), subcomp{!j}_v, !j)
next

The error message I now get is: Scalar "" sent to a function which is expecting a matrix in "COLPLACE(PRICEMAT(T,1),SUBCOMP1_V,1)"

Thanks again for your help.

Ron

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

Re: Matrix with NAs

Postby EViews Gareth » Fri Feb 19, 2016 12:35 pm

remove the (T,!j)
Follow us on Twitter @IHSEViews

ral
Posts: 23
Joined: Tue Oct 21, 2014 2:44 pm

Re: Matrix with NAs

Postby ral » Fri Feb 19, 2016 12:39 pm

Thank you, Gareth. Boneheaded error on my part.

Ron


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 9 guests