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   Scott Merryman <scott.merryman@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: -svmat- with matrix colnames based on factor variable names?
Date   Sat, 12 Feb 2011 20:46:38 -0600

On Sat, Feb 12, 2011 at 4:49 AM,  <S.Jenkins@lse.ac.uk> wrote:
> The workaround I was seeking was a quick/easy/automated way of going
> from what is shown as the contents of r(c) after -matnames- to a list of
> valid variable names that preserves the essential information. The new
> list can be used to re-label the matrix prior to -svmat-. The new names
> could be based, for instance, on the old ones but drop the ":" and "."
> from the elements of r(c), and add some prefix ("_", say) to each of the
> elements. My efforts using -subinstr- and also regular expression
> functions were not productive, but that is probably a comment on my
> skills.

Something like this?

clear*
webuse nhanes2f
logit diabetes i.hsizgp  i.black i.female age i.female#c.age, nolog

margins , at(female = 1  age = 40 hsizgp = (1(1)5) )
mat at = r(at)
matnames at
local a = r(c)
foreach l of local a {
	_ms_parse_parts `l'
	local names = "`names' `=r(name)'_`r(level)' "
}
matrix colnames at = `names'
mat list at
svmat at, names(col)


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