Statalist The Stata Listserver


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

Re: st: storing coefficients generated by nlcom


From   Maarten buis <maartenbuis@yahoo.co.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: storing coefficients generated by nlcom
Date   Fri, 24 Mar 2006 18:02:50 +0000 (GMT)

Giulio:
I think the easiest way to do it is not to store the results of -nlcom- but to store the function
in a local and use that repeatedly in -nlcom-. If you store the results of -nlcom- you do get the
variance of that statistic, but not the covariances with all other parameters and these matter
too.

Say we want the odds ratio of mpg and that odds ratio divided by the parameter of price. This is
done in example 1 below. Note that I stored the function not the value, i.e. there is no equal
sign after -local-. This means that `or' contains the string "exp(_b[mpg])" and not the number
1.2634. So after Stata has replaced the locals with their content it reads your command like
example 2. Using locals this way is not strictly necesary, you will get the same result if you
directly type in example two. But it usually makes your code a lot more readable, prefents lots of
frustrating typos and unmatched brackets. A much more elaborate example is given in
http://www.stata.com/statalist/archive/2006-03/msg00825.html .

*------------begin example 1--------------
sysuse auto, clear
logit foreign mpg price
local or exp(_b[mpg])
nlcom (or: `or') /*
  */  (nonsense: `or'/_b[price]) 
*-------------end example 1-----------------


*------------begin example 2--------------
sysuse auto, clear
logit foreign mpg price
nlcom (or: exp(_b[mpg])) /*
  */  (nonsense: exp(_b[mpg])/_b[price]) 
*-------------end example 2-----------------

HTH,
Maarten



--- Giulio Zanella <gzanella@wisc.edu> wrote:
> (1) Use nlcom to compute a nonlinear function of coefficients, say the "or" 
> function in the example below.
> (2) Use nlcom again to compute a nonlinear function of coefficients 
> *involving the previously computed function*. For this Stata needs to use 
> both coefficient and standard error of the previously computed function. 
> These are stored in r(b) and r(V), but is there an easy way to use them in 
> the nlcom command like we did with _b[mpg] below?


-----------------------------------------
between 1/2/2006 and 31/3/2006 I will be
visiting the UCLA, during this time the
best way to reach me is by email

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

visiting adress:
Buitenveldertselaan 3 (Metropolitan), room Z214

+31 20 5986715

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


		
___________________________________________________________ 
Win a BlackBerry device from O2 with Yahoo!. Enter now. http://www.yahoo.co.uk/blackberry
*
*   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–2020 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index