Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: Refer to parameter vector using variable-name abbreviation


From   Maarten buis <[email protected]>
To   [email protected]
Subject   RE: st: Refer to parameter vector using variable-name abbreviation
Date   Fri, 2 Nov 2007 12:43:14 +0000 (GMT)

-- Falko wrote:
> I want to refer to elements of the estimated parameter vector after 
> the -regress- command, using variable-name abbreviation.
<snip> 
> I want something like
>
> mat mybetas = save[1,"weight*"]
> mat list mybetas
>
> weight* not found
> r(111);

A not very elegant solution is to loop over the elements of a varlist
and build the matrix that way:

*------------- begin example ----------------
clear
use http://www.stata-press.com/data/r8/auto
generate weight2 = weight^2
generate weight3 = weight^3
reg mpg price weight*

mat save = e(b)

local i = 1
foreach var of varlist weight* {
	if `i' == 1 {
		local `i' = `i' + 1
		mat mybetas = save[1,"`var'"]
	}
	else {
		mat mybetas = mybetas \ save[1,"`var'"]
	}
}
mat list mybetas 
*------------------ end example --------------------
(For more on how to use examples I sent to the Statalist, see
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )

Hope this helps,
Maarten

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      ___________________________________________________________ 
Want ideas for reducing your carbon footprint? Visit Yahoo! For Good  http://uk.promotions.yahoo.com/forgood/environment.html
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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