Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# Re: st: graph the fitted values in a 3-way interaction with additional covariates

 From "Gentile, Elisabetta" To statalist@hsphsun2.harvard.edu Subject Re: st: graph the fitted values in a 3-way interaction with additional covariates Date Tue, 28 May 2013 11:12:13 +0800

Dear Richard,

Thanks for your suggestion.  Allow me to build on your example to
clarify my issue:

webuse nhanes2f, clear
regress health c.age##female##black height weight

Since I want to find the slopes of 'health' on 'age' for each interaction, I do:

margins female#black, dydx(age)

At this point, I want to plot said slopes for each interaction.

Now, it is my understanding that if I do:

twoway lfit health age, by(female black)

Stata will plot the fitted values from a different regression:

regress health c.age##female##black

that is, the effect of the other covariates is not there.

I am trying to override the defaults on marginsplot to get what I
want, but so far I have not found the right syntax.

Your thoughts on the issue are much appreciated.

Elisa

On Sat, May 25, 2013 at 12:18 AM, Richard Williams
<richardwilliams.ndu@gmail.com> wrote:
> How about something like this?
>
> webuse nhanes2f, clear
> reg health c.age##female##black height weight
> margins female#black, at(age=(20(5)70))
> marginsplot
>
> You could use the -atmeans- option or otherwise specify values for the other
> covariates.
>
>
>
> At 07:26 AM 5/24/2013, Gentile, Elisabetta wrote:
>>
>> Dear StataListers,
>>
>> I have a dataset of firms grouped by country and sector of operation.
>> I run a linear probability model with a three-way interaction, where
>> my dependent variable Y is obviously a binary indicator, my
>> independent variable X is continuos on [0,1], the modifier W is a
>> binary indicator, and Z is a categorical variable that splits the data
>> into three groups.
>>
>> I want to graph the slopes for each of the interactions, so that if I
>> have the simple regression:
>>
>> regress Y c.X##W##Z
>>
>> then for example I can do:
>>
>> twoway lfit Y X, by(W Z)
>>
>> which generates six charts with the slopes for each group.
>>
>> The problem is that my model has additional covariates, such as sector
>> and year fixed effects, and other continuous variables both at the
>> country and firm level.
>>
>> How do I graph the slopes for each of the interactions for the model
>> including all the covariates?  The first thing that came to mind was
>> avplot, but it does not accept the by() option, so I am at a loss
>> here.  There must be a simple solution that I am not seeing!  Your
>> input is much appreciated.
>>
>> Regards,
>> Elisa
>> *
>> *   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/
>
>
> -------------------------------------------
> Richard Williams, Notre Dame Dept of Sociology
> OFFICE: (574)631-6668, (574)631-6463
> HOME:   (574)289-5227
> EMAIL:  Richard.A.Williams.5@ND.Edu
> WWW:    http://www.nd.edu/~rwilliam
>
>
> *
> *   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/
*
*   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/