Statalist The Stata Listserver


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

Re: st: mediation analysis


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: mediation analysis
Date   Fri, 18 May 2007 14:45:42 +0100 (BST)

--- Garth Rauscher <[email protected]> wrote:
> I'd like to modify the program to calculate the differences in the
> excess ***Y-standardized*** odds ratios but don't know how to tell
> Stata that.
> Instaed of using _b(variable_name) for the unstandardized ORs, do you
> happen to know how to ask for the Y-standardized estimate? I tried
> _b[bStdy] but Stata did not recognize that.

_b[whatever] means the the element out of the e(b) matrix for the
variable whatever. The e(b) matrix is the matrix of raw coefficients,
so in the case of -logit- these are the log odds ratios (so my original
program contained an error: it didn't look at the changes in odds
ratios but in log odds ratios). So _b[bStdy] will not give you the
standardized coefficients, if you have no variable bStdy than it will
give you nothing.

The standardized coefficients can be obtained using the -listcoef-
command, which is part of the spost package. You can install that
package by typing findit spost and follow the instructions. Once you've
installed the spost package you can run the example below. It uses some
matrix commands to extract the relevant numbers from the matrix, see:
-help matrix_functions- for explanations of the -el- and -colnumb-
functions.

*----------- begin example -----------
set more off
sysuse auto, clear
recode rep78 1/3=0 4/5=1
capture program drop difodds
program define difodds, rclass
	logit rep78 foreign
	listcoef, std matrix
	tempname womed std
	matrix `std' = r(b_ys)
	scalar `womed' = el(`std',1,colnumb(`std',"foreign"))
	logit rep78 foreign price mpg
	listcoef, std matrix
	tempname wmed
	matrix `std' = r(b_ys)
	scalar `wmed' = el(`std',1,colnumb(`std',"foreign"))
	return scalar dif = (`wmed'-`womed')/`womed'*100
end
bootstrap dif=r(dif), reps(100): difodds
*---------- 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/
-----------------------------------------


      ___________________________________________________________ 
Yahoo! Mail is the world's favourite email. Don't settle for less, sign up for
your free account today http://uk.rd.yahoo.com/evt=44106/*http://uk.docs.yahoo.com/mail/winter07.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