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]

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


From   Austin Nichols <[email protected]>
To   [email protected]
Subject   Re: st: -svmat- with matrix colnames based on factor variable names?
Date   Fri, 11 Feb 2011 13:23:22 -0500

Stephen--
Why do you need the names option on -svmat-?  You can also write a
little loop to save the matrix to variables/obs on your data, without
putting illegal names on variables. But either way, you will have to
figure out what you want to call a variable that wants to be named
0b.edlevel or whatever.
If you provide an example with public data, I will come up with a few
solutions for you.

On Fri, Feb 11, 2011 at 12:22 PM,  <[email protected]> wrote:
> 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

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