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

From |
Jeph Herrin <junk@spandrel.net> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: tips on reading large matrix from ASCII file? |

Date |
Tue, 02 Dec 2008 15:09:09 -0500 |

Solved, but there may be better ways: I used -file- to read the ASCII file a line at a time and write out a -do- file which contained the necessary lines to -matrix input- the values. This works beautifully in that the process is entirely automated. I did have to create row vectors and combine them with "\", as the whole matrix was too big to input at once. Here's the top of the automatically generated -do- file; I then just run the do file to create the vector and VC matrices: #delimit ; matrix input b = (

2.3341741 2.0369928 -0.0271400 0.0421754 -0.0549200 ) ; And so on. cheers, Jeph Jeph Herrin wrote:

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. Jeph * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

* * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: tips on reading large matrix from ASCII file?***From:*"Stas Kolenikov" <skolenik@gmail.com>

**References**:**st: tips on reading large matrix from ASCII file?***From:*Jeph Herrin <junk@spandrel.net>

- Prev by Date:
**RE: st: ranking with weights** - Next by Date:
**st: Length for strings, ignoring SMCL tags** - Previous by thread:
**st: tips on reading large matrix from ASCII file?** - Next by thread:
**Re: st: tips on reading large matrix from ASCII file?** - Index(es):

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