Page 1 of 1

Matrix with NAs

Posted: Fri Feb 19, 2016 11:58 am
by ral
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

Re: Matrix with NAs

Posted: Fri Feb 19, 2016 12:14 pm
by EViews Gareth
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.

Re: Matrix with NAs

Posted: Fri Feb 19, 2016 12:29 pm
by ral
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

Re: Matrix with NAs

Posted: Fri Feb 19, 2016 12:35 pm
by EViews Gareth
remove the (T,!j)

Re: Matrix with NAs

Posted: Fri Feb 19, 2016 12:39 pm
by ral
Thank you, Gareth. Boneheaded error on my part.

Ron