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

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: 11930
Joined: Tue Sep 16, 2008 5:38 pm

### Re: Matrix with NAs

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.

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

### Re: Matrix with NAs

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)"

Ron

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

### Re: Matrix with NAs

remove the (T,!j)

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

### Re: Matrix with NAs

Thank you, Gareth. Boneheaded error on my part.

Ron