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

# Re: st: margins on continuous interactions.

 From Natasha Agarwal To statalist@hsphsun2.harvard.edu Subject Re: st: margins on continuous interactions. Date Tue, 10 Dec 2013 10:52:00 +0530

```Hi Alfonso,

I do put the constituent terms of the interaction term. Accordingly, I
estimate the following model:

xtreg y x1 x2 x3 x4 x3#x4 year dummies, fe vce(robust)

In this case x4, which is the industry variable, drops out because it
is not time invariant. Do you think margins is not estimate because of
this?

I agree that the estimated coefficients from -xtreg, fe, are the same
when using margins. However, I would not get it for each industry if I
run the above specification. When I estimate the above specification,
I get an average impact of x3. However, I would like to know the
average impact of x3 for different values of x4. I can try to overcome
this by estimating the above specification for each value of x4 (in
this case I would not need the interaction term). However, the sample
size reduces drastically. Hence, I explored the margins command.
However, I am still not sure what it is doing, and why is it not
estimating, and whether using the noestimcheck option is correct.

Best,
Natasha

On Mon, Dec 9, 2013 at 8:39 PM, Alfonso Sánchez-Peñalver
<alfonso.statalist@gmail.com> wrote:
> Hi Natasha,
>
> my question was related to why you don’t include the actual variables of x3 and x4 but only the interaction. when x3 changes it will affect the probability by itself (unless the coefficient on x3 is insignificant) and because of its interaction with x4. If the coefficient of x3 (on itself) is not insignificant you are omitting a relevant variable and your estimates of the coefficients will be biased. The estimate of the marginal effect of x3 would also be wrong, because in reality it would be b3 (the marginal effect of x3) + b34 0.15 (where b34 is the marginal effect of the interaction variable). Margins is able to automatically incorporate both if you enter x3##x4 (or x3 x3#x4 if you want to leave x4 out for some reason) into your -xtreg- command. I also have a question of why do you expect the standard errors returned by margins when calculating the marginal effects (dydx) to be any different from those returned from -xtreg-. In -xtreg- the marginal effects on the respon!
se!
>   variable are already the estimated coefficients, and thus the standard errors returned by -xtreg- are the appropriate ones. That is why I said that there would be no variation.
>
> Best,
>
> Alfonso.
>
> On Dec 9, 2013, at 12:14 AM, Natasha Agarwal <agarwana6@gmail.com> wrote:
>
>> Dear Alfonso,
>>
>> So x4 in my case represents 27 industries, and each industry has a
>> value. For instance, x4 for industry one is 0.15, but for industry 2
>> is 0.20. The reason I want to use margins so that I am able to get the
>> p-values and the confidence intervals for x3 for each value of x4.
>> Besides, I want to plot a marginsplot for the same.
>>
>> Can someone tell me if the scaling is an issue in using the margins
>> command in my case, and whether to use noestimchek option is correct ?
>>
>> Best,
>> Natasha
>>
>> On Fri, Dec 6, 2013 at 5:43 PM, Alfonso Sanchez-Penalver
>> <alfonso.statalist@gmail.com> wrote:
>>> Hi Natasha,
>>>
>>> On a different note to what Jeff suggested you are only introducing the interaction term between x3 and x4, not the actual levels of the variables. You then want to know the marginal effect of x3 at x4=0.15. That is simply the coefficient on the interaction term times 0.15. There is no variation. So what are you expecting margins to do?
>>>
>>> Best,
>>>
>>> Alfonso Sanchez-Penalver
>>>
>>>> On Dec 6, 2013, at 12:33 AM, Natasha Agarwal <agarwana6@gmail.com> wrote:
>>>>
>>>> Dear Jeff,
>>>>
>>>> Thank you for your help.
>>>>
>>>> The codes are as follows
>>>>
>>>> ******
>>>> xtset firm year
>>>> xtreg y x1 x2 c.x3#c.x4 i.year, fe vce(robust)
>>>> margins, dydx(x3) at(x4=0.15)
>>>>
>>>> *****
>>>>
>>>> In the above codes: y = varies at firm and time, x1 = varies at firm
>>>> and time, x2 = varies at firm and time, x3 = varies at industry region
>>>> and time, x4 = varies at industry only.
>>>>
>>>> I looked at the advised archives Statalist option, and I went ahead
>>>> with it. However, I am not sure if noestimcheck is the right option?
>>>> Can you please explain me if possible on how would one know when to
>>>> use the noestimcheck option?
>>>>
>>>> Thank you very much again and sorry for taking your time.
>>>>
>>>> Best,
>>>> Natasha
>>>>
>>>>
>>>> On Thu, Dec 5, 2013 at 10:53 PM, Jeff Pitblado, StataCorp LP
>>>>> Natasha Agarwal <agarwana6@gmail.com> is using -margins- after -xtreg, fe- but
>>>>> is getting (not estimable) for the requested marginal effect:
>>>>>
>>>>>> I estimate a fixed effect model xtreg y x1 x2 x3*x4 year dummies, fe
>>>>>> vce(robust)
>>>>>>
>>>>>> where y, x1, x2, are firm level variables. x3 changes over
>>>>>> industry-region-year. while x4 changes only over industry. After this, I
>>>>>> estimate margins, dydx(x3) at(x4 = 0.15). I get a not estimable error. I
>>>>>> then try to use the noestimcheck option, and state margins, dydx(x3)
>>>>>> at(x=0.15) noestimcheck. and I get an output. However I am not sure whether
>>>>>> it is correct to use the noestimcheck option here.
>>>>>
>>>>> Natasha identifies several grouping variables (firm, industry, region, year)
>>>>> but does not indicate which grouping variable was -xtset- as the panel
>>>>> variable so it is very difficult to reproduce the problem.
>>>>>
>>>>> Even if we cannot have access to Natasha's data, showing us all the relevant
>>>>> Stata code would have been more helpful.  Something like
>>>>>
>>>>>> The code I used was
>>>>>>
>>>>>> ***** BEGIN:
>>>>>> xtset ???panelvariable???
>>>>>> xtreg y x1 x2 c.x3#c.x4 i.year, fe vce(robust)
>>>>>> margins, dydx(x3) at(x4=0.15)
>>>>>> ***** END:
>>>>>
>>>>> I suspect Natasha is experiencing scaling problems.  -margins- can have a
>>>>> difficult time in checking for estimable functions when crossed continuous
>>>>> variables are on very different scales.
>>>>>
>>>>> If my suspicions are correct, then I imagine the advice at the end of the
>>>>> following post is relevant for Natasha as well.
>>>>>
>>>>>       http://www.stata.com/statalist/archive/2011-07/msg00514.html
>>>>>
>>>>> --Jeff
>>>>> *
>>>>> *   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/
>>>
>>> *
>>> *   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/
>
>
> *
> *   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/
```