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: RE: -svmat- with matrix colnames based on factor variable names?
From
Nick Cox <[email protected]>
To
"'[email protected]'" <[email protected]>
Subject
st: RE: -svmat- with matrix colnames based on factor variable names?
Date
Fri, 11 Feb 2011 18:13:36 +0000
I don't have a positive solution but I do note -svmat- was written for version 4 and so it is indeed unlikely to support factor variables. So any pre-processing for -svmat- would have to find a work-around for that.
Nick
[email protected]
[email protected]
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).
*
* 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/