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: RE: Re: Marginal effects after ivreg2


From   "Schaffer, Mark E" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: RE: Re: Marginal effects after ivreg2
Date   Tue, 14 Jan 2014 11:15:33 +0000

Suyin,

> -----Original Message-----
> From: Suyin Chang [mailto:[email protected]]
> Sent: 14 January 2014 06:19
> To: [email protected]; Schaffer, Mark E
> Subject: Re: st: RE: Re: Marginal effects after ivreg2
> 
> Dears Jana and Mark,
> 
> Very interesting question, followed by a promising reply.
> However, I would like to ask two quick follow-up questions, if I may.
> 
> The first problem is I don't get how to mimic -margins- with -nlcom- after
> ivreg2 in case we want a linear plot. For instance, how to mimic something
> like margins, dydx(mgp) at(turn=(start(by)end)), where start is the first value
> and end is the last value of the variable turn to be considered? That appears
> to me as something less intuitive to achieve.

This is also easy to do - all you need to do is loop through the values and apply -nlcom- each time.  Here is a modified version of my original example with -regress-:

sysuse auto, clear
gen mpgturn=mpg*turn

regress price mpg turn mpgturn
forvalues x=31(1)51 {
	nlcom _b[mpg] + _b[mpgturn]*(`x')
}

regress price mpg turn c.mpg#c.turn
margins, dydx(mpg) at(turn=(31(1)51))

> And the second thing is to ask if there is a way to easily plot those results
> such as marginsplot does with margins saved output.

Maybe someone else has some suggestions here...?

--Mark

 
> Any suggestions would be very much appreciated, as I am facing the same
> need as Jana in the original question, i.e. I need to generate a marginal
> effects plot for an interaction between the endogenous explanatory variable
> and a exogenous explanatory variable (both continuous).
> 
> Thanks,
> 
> Suyin
> 
> 
> 
> 
> 
> 2013/12/26 Schaffer, Mark E <[email protected]>:
> > Jana,
> >
> > -ivreg2- doesn't (yet - we really need to add this in!) support -margins-.  But
> an easy workaround is to use -nlcom- with -ivreg2-.
> >
> > Below is an example of how to use -nlcom- to mimic -margins- to calculate
> marginal effects and CIs when you have an interaction.
> >
> > HTH,
> > Mark
> >
> > sysuse auto, clear
> > gen mpgturn=mpg*turn
> > regress price mpg turn mpgturn
> > qui sum turn, meanonly
> > nlcom _b[mpg] + _b[mpgturn]*(`r(mean)') qui sum mpg, meanonly nlcom
> > _b[turn] + _b[mpgturn]*(`r(mean)') regress price mpg turn c.mpg#c.turn
> > margins, atmeans dydx(*)
> >
> >> -----Original Message-----
> >> From: [email protected] [mailto:owner-
> >> [email protected]] On Behalf Of Jana von Stein
> >> Sent: 26 December 2013 01:59
> >> To: <[email protected]>
> >> Subject: st: Re: Marginal effects after ivreg2
> >>
> >> Hello,
> >>
> >> I need to run margins (or calculate marginal effects with ci's) after
> >> ivreg2. I have an endogenous interaction and want to calculate the
> >> marginal effect (w/
> >> ci's) after ivreg2. Does anyone know how to do this? Margins did not
> >> seem to work after ivreg2.
> >>
> >> Thanks, and happy holidays.
> >> Jana
> >>
> >>
> >>
> >>
> >> *
> >> *   For searches and help try:
> >> *   http://www.stata.com/help.cgi?search
> >> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> >> *   http://www.ats.ucla.edu/stat/stata/
> >
> >
> > -----
> > Sunday Times Scottish University of the Year 2011-2013 Top in the UK
> > for student experience Fourth university in the UK and top in Scotland
> > (National Student Survey 2012)
> >
> > We invite research leaders and ambitious early career researchers to
> > join us in leading and driving research in key inter-disciplinary themes.
> > Please see www.hw.ac.uk/researchleaders for further information and
> > how to apply.
> >
> > Heriot-Watt University is a Scottish charity registered under charity
> > number SC000278.
> >
> >
> > *
> > *   For searches and help try:
> > *   http://www.stata.com/help.cgi?search
> > *   http://www.stata.com/support/faqs/resources/statalist-faq/
> > *   http://www.ats.ucla.edu/stat/stata/


----- 
Sunday Times Scottish University of the Year 2011-2013
Top in the UK for student experience
Fourth university in the UK and top in Scotland (National Student Survey 2012)


We invite research leaders and ambitious early career researchers to 
join us in leading and driving research in key inter-disciplinary themes. 
Please see www.hw.ac.uk/researchleaders for further information and how
to apply.

Heriot-Watt University is a Scottish charity
registered under charity number SC000278.


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index