[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: tips on reading large matrix from ASCII file?

From   Jeph Herrin <>
Subject   st: tips on reading large matrix from ASCII file?
Date   Tue, 02 Dec 2008 13:43:11 -0500

I've used HLM6 to run a large number of mixed effects models,
each model producing an ASCII file which contains the fixed
effects and variance-covariance matrix. There are 60+ variables,
but for whatever reason HLM6 only writes 60 values per line,
so one ASCII file (with 65 terms) looks like this

 F1   F2   .. ....   ...  F60
 F61  F62  F63  F64  F65          // 65 coeffs on two rows
 V11  V12   .. ....   ...  V160
 V161 V162 V163 V164 V165         // then 65x65 VC entries on
 V21  V22   .. ....   ...  V260   //  2 x 65 lines
 V261 V262 V263 V264 V265
 V651  V652   .. ....   ... V6560  // last row of VC matrix on
 V6561 V6562 V6563 V6564 V6565     //   two lines

(where the ASCII file doesn't have the comments).

Since this is a fairly rigid format that depends only on
N, the number of covariates, I thought it would be a small
matter to -infile- this with a -dct- file and store it as
a matrix. However, -infile- requires me to write out every
single variable name, and to modify the number of variables
in the -dct- file according to the number of covariates.

In the past, I have used PERL to parse these files, but
I'm doing this on a new box and figured instead of reinstalling
PERL I'd try to sort it out in Stata. Is there an easier way
convert this file to a matrix (actually a vector for the first
two lines and a matrix for the remainder)?

Thanks for any suggestions.

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index