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: Obtaining 95%CI for marginal effect


From   Steven Samuels <[email protected]>
To   [email protected]
Subject   Re: st: Obtaining 95%CI for marginal effect
Date   Mon, 7 Feb 2011 09:20:09 -0500

On Feb 6, 2011, at 11:48 PM, Nur Hafidha Hikmayani wrote:


1. Is it at our discretion to adjust to rep78=3 (from your example)
considering perhaps that the 'risk' is higher at rep78=3, or was the
choice based on the largest proportion?

I chose rep78 because it was in the middle of the range. But with a small number of categorical variables, I would produce predictions at 2+ levels, not just the "middle" level. This is mandatory if you have interactions.

2. Why Stata gave error mesage when another numerical variable was added:
adjust weight=3138.575 turn=40.33816 _Irep78_2=0 _Irep78_3=1
_Irep78_4=0 _Irep78_5=0, by(foreign) ci se

I assume you first ran: "xi: svy: reg mpg weight turn i.foreign i.rep78"

I don't get an error when I paste your command into the do file editor. Without seeing the Stata log, starting with your -regress-- statement and ending with the error message and number (as requested by the FAQ), it's impossible to say what your mistake is.

Steve
[email protected]

On Sun, Feb 6, 2011 at 11:08 PM, Steven Samuels <[email protected]> wrote:

The method I showed will work for indicator variables too, but I, for one, don't understand what is represented when indicators for variables with >2
 categories are set to their means.  (-svy: prop- won't help, as for k
categories, it gives k proportions). Much better, I think, to set the other categorical variables to typical values. e.g., for the auto data set:

 xi: svy: reg mpg weight i.foreign i.rep78
 // adjust to rep78=3
adjust weight=3138.575 _Irep78_2=0 _Irep78_3=1 _Irep78_4=0 _Irep78_5=0,
by(foreign)

For non-linear models like -logistic-, setting variables to their means can
produce unexpected results.  See:
http://www.stata.com/statalist/archive/2010-07/msg01596.html and Michael
Norman Mitchell's follow-up.


Note: Your original formulation in -mfx- looks incomplete. You specified "at_Imedgrp_1=0 _Imedgrp_2=0" But medgrp had four levels,( 0,1,2,3), since -xi- produced three indicator variables. Your specification was equivalent
to saying: at medgrp==0 or medgrp==3. Is this what you intended?

Steve


On Feb 6, 2011, at 9:59 AM, Nur Hafidha Hikmayani wrote:

Thanks Steve.
I'm afraid however that I'm not clear enough when some independent
variables are categorical. You gave an example in which weight and
turn are numerical variables - in my case, there is only 1 numerical
IV. Suppose foreign is the main IV of interest and other covariates
are mostly categorical, can we use -adjust- too (perhaps with
-svy:prop- beforehand instead)?

hafida-

On Sun, Feb 6, 2011 at 9:12 PM, Steven Samuels <[email protected]> wrote:

Nur-

I apologize. I checked and discovered -adjust- after -svy: reg- does not compute predictions at the weighted means of the covariates, only at the
unweighted means. As a work-around, you could substitute the weighted
means
by hand.

****************************
sysuse auto, clear
drop if rep78==.
svyset rep78 [pw=head]
svy: mean weight turn   //get survey weighted means
xi: svy: reg mpg weight turn i.foreign
adjust weight= 3138.575 turn=40.33816, by(foreign) ci se
*****************************

Steve
[email protected]


Nur-

Use -adjust- with the -ci- option.  The fitted value of y is not a
"marginal
effect"; for -regress- or (-svy: regress-) the default marginal effects
are
the regression coefficients.

*********************
sysuse auto, clear
xi: reg weight price turn i.foreign
adjust price turn, by(foreign), se ci
******************

Steve
[email protected]

On Feb 6, 2011, at 7:02 AM, Nur Hafidha Hikmayani wrote:

Dear all,
I've been running some regression models using -svy- and estimating
its marginal effect using -mfx- (I use Stata 10.1).
I wonder how can I get the 95% CI for the marginal effects (y)?

The output for regression and its marginal effect are as follows:

. xi: svy: reg GH i.medgrp exgrp chronic nummed gp

------------------------------------------------------------------------------
        |             Linearized
GH | Coef. Std. Err. t P>|t| [95% Conf. Interval]

------------- +----------------------------------------------------------------
_Imedgrp_1 |   4.429839    3.56263     1.24   0.214    -2.564628
 11.42431
_Imedgrp_2 |   8.333728   3.633545     2.29   0.022     1.200035
 15.46742
_Imedgrp_3 |   10.05818   3.773961     2.67   0.008     2.648813
 17.46755
exgrp | -8.916839 1.89046 -4.72 0.000 -12.62835 -5.205324 chronic | -10.31767 1.936802 -5.33 0.000 -14.12017 -6.515169 nummed | -1.063043 .3452676 -3.08 0.002 -1.740902 -. 3851831 gp | -4.347845 1.773649 -2.45 0.014 -7.830027 -. 865663 _cons | 83.19335 3.520136 23.63 0.000 76.28231 90.10438

------------------------------------------------------------------------------

. mfx, at(mean _Imedgrp_1=0 _Imedgrp_2=0)
Marginal effects after svy:regress
 y  = Fitted values (predict)
    =  53.085624

------------------------------------------------------------------------------
variable |      dy/dx    Std. Err.     z    P>|z|  [    95% C.I.   ]
 X

--------- +--------------------------------------------------------------------
_Imedg~1*|   4.429839     3.56263    1.24   0.214  -2.55279  11.4125
0
_Imedg~2*|   8.333728     3.63354    2.29   0.022   1.21211  15.4553
.379185
_Imedg~3*|   10.05818     3.77396    2.67   0.008   2.66136   17.455
0
exgrp*|  -8.916839     1.89046   -4.72   0.000  -12.6221 -5.21161
.762312
chronic*|  -10.31767      1.9368   -5.33   0.000  -14.1137 -6.52161
 .83752
nummed |  -1.063043      .34527   -3.08   0.002  -1.73975 -.386331
6.69376
gp*| -4.347845 1.77365 -2.45 0.014 -7.82413 -.871558 . 472814

------------------------------------------------------------------------------
(*) dy/dx is for discrete change of dummy variable from 0 to 1


Any help is much appreciated,
Thanks,
hafida-

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

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


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

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


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

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