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: Marginal Effects using subsetted data
From
Richard Williams <[email protected]>
To
[email protected]
Subject
Re: st: Marginal Effects using subsetted data
Date
Sun, 31 Oct 2010 19:37:18 -0500
At 02:54 PM 10/31/2010, MOSTARDO, NICK wrote:
Hello,
I am running an ordered probit model using data that I wish to subset by
gender and race (both dichotomous measures). I am running the following
commands:
'by gender race, sort: ologit depvar indvars'
At that point, I get the correct output of 4 tables for the proper
combinations of the sorted variables (0,0)(0,1)(1,0)(1,1); however, when
I try to run marginal effects as:
'mfx, predict(p outcome(1))' (my depvar is 3 ordered categories)
I get the error:
'no observations
r(2000);'
As a sidelight, you might want to use mfx2 or margeff instead of mfx
when running commands like oprobit. Both will give you the marginal
effects for all the outcomes at once, instead of having to give a
command for each outcome. Both also give you the option of storing
the results, which can be handy for creating tables. Both are
available from SSC. Slightly tweaking Kit's example,
clear all
set more off
sysuse auto
drop if rep78==1
su price,mean
g hip = price>r(mean)
forv p=0/1 {
forv f=0/1 {
di in r _n "High price==`p', Foreign==`f'"
oprobit rep78 turn mpg if hip==`p' & foreign==`f', nolog
mfx, predict(p outcome(#1))
mfx2, nolog
}
}
If I ever get ambitious, I may try to update mfx2 so it works with
factor variables and the margins command. Having to give separate
commands for each outcome is kind of a pain and it makes the output
harder to read.
-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
HOME: (574)289-5227
EMAIL: [email protected]
WWW: http://www.nd.edu/~rwilliam
*
* 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/