Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: -svmat- with matrix colnames based on factor variable names?


From   <S.Jenkins@lse.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: -svmat- with matrix colnames based on factor variable names?
Date   Fri, 11 Feb 2011 17:22:53 -0000

I'm having difficulty using a list of factor variable names to construct
the column names of a matrix post-estimation. 

This arises when using -margins, over(.)- with multiple -at(.)- options.
I want to collect to collect all the estimates in a matrix with one row
per at/over combination, with additional columns also containing values
for the at values chosen. To keep track, I want the column names for the
additional at columns to contain names that identify the factor
variables.  

Overall aim: once I have created the summary matrix , I want to convert
each of the columns to a variable, with all the at variables -- together
with other variables containing estimates and SE -- to be saved to a
separate mini-dataset, and used for graphing or table processing. 

I am currently using -svmat- and it chokes on the factor variable names.
As they contain ".", I suspect that the command does not like them.
Here's some sample output:

===================== 
. margins, post over(agegp3)
///
>    at( edlevel = 0 latecomer = 0 htenure = 3 gregion = 3 carinhh = 0
hlpoor = 1    ///
>       mstatus = 1 responkids = 1 hhsize = 4 ageygestlt5 = 1 )
///
>
/// 
>    at( edlevel = 2 latecomer = 0 htenure = 2 gregion = 7 carinhh = 1
hlpoor = 0    ///
>        mstatus = 1 responkids = 0 hhsize = 2 ageygestlt5 = 1 )   
<snip>
-- Code extracting the estimates, and their SE, and converting to
variables
<snip>
.   mat at = e(at)
.   mat at = at[1...,7...]   // matrix of at(.) values, excluding cols
with missing (over var)
.   svmat at, names(col)
invalid syntax
r(198);

end of do-file

r(198);
=====================

A -mat list at- shows that the column names of matrix at include names
such as "0b.edlevel, 1.edlevel, 0b.latecomer,  1.latecomer, ..." 

I have tried using -matnames- (by Austin Nichols, on SSC) to extract the
names and apply them in the -svmat- call, but also get a syntax error.
Statalist Archive searches have not revealed anything for me (or I may
not have searched correctly). 

Is there a work-around please?  

Stephen
-------------------------------------
Stephen P. Jenkins  <s.jenkins@lse.ac.uk>
Department of Social Policy and STICERD/CASE
London School of Economics and Political Science
Houghton Street
London WC2A 2AE, U.K.
Tel. +44 (0)20 7955 6527
Survival Analysis using Stata:
http://www.iser.essex.ac.uk/survival-analysis
Downloadable papers and software: http://ideas.repec.org/e/pje7.html


Please access the attached hyperlink for an important electronic communications disclaimer: http://lse.ac.uk/emailDisclaimer

*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index