Deleting a column from a matrix (and a row from a vector)

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason

wags
Posts: 5
Joined: Wed May 01, 2013 1:45 pm

Deleting a column from a matrix (and a row from a vector)

Postby wags » Mon May 06, 2013 5:54 am

Hi,

I am estimating G regressions and storing a scalar from each regression in a row vector and a computed data series (nobs x 1) in each column of a matrix. Upon completion, I have a (Gx1) row vector and a (nobs X G) matrix. Later in the program, I multiply the (matrix * row vector). No problem.

For a few iterations, the computed series cannot be calculated so the column that is placed in the matrix has NAs. Needless to say, the computation of the (matrix * row vector) fails when this happens.

Is there a way that I could: (a) check for NAs in the (nobs x G) matrix when all of the iterations are completed and (b) delete the corresponding columns in the matrix and rows in the row vector for which NAs appear?

Thanks for your help.

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

Re: Deleting a column from a matrix (and a row from a vector

Postby EViews Gareth » Mon May 06, 2013 7:46 am

Not easy to do either.

Perhaps the best way to check for NAs is to check that each column has the same number of observations. You can use @cobs to do that. If you know how many observations should be in each column, you could just check whether the mimimum of @cobs is equal to the proper number.


In EViews 8 the best way to delete rows/columns from a matrix is to use the @droprow data member of a matrix.

wags
Posts: 5
Joined: Wed May 01, 2013 1:45 pm

Re: Deleting a column from a matrix (and a row from a vector

Postby wags » Mon May 06, 2013 12:36 pm

Thanks. I'll play around with your suggested approach.

Would this alternative approach be feasible?

Will EViews allow you to expand a matrix dynamically? For instance, I could create and initial column vector (of 0's or something) and then concatenate a new column if that column does not contain NAs. This would yield a final matrix of only numerical values.

wags
Posts: 5
Joined: Wed May 01, 2013 1:45 pm

Re: Deleting a column from a matrix (and a row from a vector

Postby wags » Mon May 06, 2013 12:36 pm

Thanks. I'll play around with your suggested approach.

Would this alternative approach be feasible?

Will EViews allow you to expand a matrix dynamically? For instance, I could create and initial column vector (of 0's or something) and then concatenate a new column if that column does not contain NAs. This would yield a final matrix of only numerical values.

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

Re: Deleting a column from a matrix (and a row from a vector

Postby EViews Gareth » Mon May 06, 2013 12:45 pm

There's a @hcat function that will concatenate.


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 2 guests