gllamm, gllapred, and marginal effects

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

gllamm, gllapred, and marginal effects

richard boylan-2
I am trying to obtain the marginal effect after using gllamm.

I have looked at prior posts which explain that one cannot use the command mfx
and one should instead use the command gllapred.

However, I don't quite see how it is equivalent.

I am putting an example next that I ran with STATA 10.

use http://www.ats.ucla.edu/stat/paperexamples/singer/hsb12.dta
gen gm = (matach > 10)
logit gm minority female
mfx

gives me

variable |      dy/dx    Std. Err.     z    P>|z|  [    95% C.I.   ]      X
---------+--------------------------------------------------------------------
minority*|  -.2380667      .01292  -18.43   0.000   -.26339 -.212743   .274739
  female*|  -.0772496      .01146   -6.74   0.000  -.099714 -.054785   .528184
------------------------------------------------------------------------------

I would like to be able to replicate this with gllamm, just to make
sure that I understand
what I am doing.

gllamm gm minority female , i(one)  link(logit)
gllapred pred, mu marg

Now my question is how do I go from here to obtaining the coefficient
for dy/dx and Std.Err.
that I obtained with mfx?

Richard
*
*   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/
Reply | Threaded
Open this post in threaded view
|

Re: gllamm, gllapred, and marginal effects

Stas Kolenikov
On Wed, Dec 8, 2010 at 10:51 AM, richard boylan <[hidden email]> wrote:
> I am putting an example next that I ran with STATA 10.
>
> use http://www.ats.ucla.edu/stat/paperexamples/singer/hsb12.dta
> gen gm = (matach > 10)

matach not found
r(111);

--
Stas Kolenikov, also found at http://stas.kolenikov.name
Small print: I use this email account for mailing lists only.
*
*   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/
Reply | Threaded
Open this post in threaded view
|

Re: gllamm, gllapred, and marginal effects

richard boylan-2
Sorry!!! (copy and pasted the part of the code where I made a typo)

Here is the correct one

gen gm = (mathach > 10)

On Wed, Dec 8, 2010 at 11:05 AM, Stas Kolenikov <[hidden email]> wrote:

> On Wed, Dec 8, 2010 at 10:51 AM, richard boylan <[hidden email]> wrote:
>> I am putting an example next that I ran with STATA 10.
>>
>> use http://www.ats.ucla.edu/stat/paperexamples/singer/hsb12.dta
>> gen gm = (matach > 10)
>
> matach not found
> r(111);
>
> --
> Stas Kolenikov, also found at http://stas.kolenikov.name
> Small print: I use this email account for mailing lists only.
> *
> *   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/
Reply | Threaded
Open this post in threaded view
|

Re: gllamm, gllapred, and marginal effects

Stas Kolenikov
On Wed, Dec 8, 2010 at 11:22 AM, richard boylan <[hidden email]> wrote:
> Sorry!!! (copy and pasted the part of the code where I made a typo)
>
> Here is the correct one
>
> gen gm = (mathach > 10)
>

math achievement, not mother attachment :)

--
Stas Kolenikov, also found at http://stas.kolenikov.name
Small print: I use this email account for mailing lists only.
*
*   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/
jsw
Reply | Threaded
Open this post in threaded view
|

Re: gllamm, gllapred, and marginal effects

jsw
This post has NOT been accepted by the mailing list yet.
In reply to this post by richard boylan-2
One circuitous option is to run the -gllamm- command through -xtlogit-, and then use run -margins- (or mfx).  Credit goes to David Jaeger who posted the solution on the Statalist in 2006 (http://statalist.blogspot.com/2006/03/re-st-gllamm-and-marginal-effects.html).  

For a random effects probit model, here's a slightly modified version of Jaeger's code:

gllamm y x1 x2 x3 , i(id) link(probit) fam(binom) adapt
matrix a=e(b)
* local n=colsof(a)
* matrix a[1,`n']=ln(a[1,`n'])
xtprobit y x1 x2 x3 , re i(id) from(a,copy) intpoints(30) iterate(0)
margins, dydx(*) predict(pu0)

I commented out two lines, because the code wouldn't run with them and I seemed to be getting the correct answers without them.  If they are essential, I would love to know.  

This approach can be modified for -xtlogit- and many other estimation commands.  

Justin
Reply | Threaded
Open this post in threaded view
|

Re: gllamm, gllapred, and marginal effects

aaron
This post has NOT been accepted by the mailing list yet.
Dear jsw,

I've been looking for the solution for this question for quite a while and feel so exited to see this post. As I am a beginner and do not have sufficient skill to make the modification, could you please explain how this can be adapted to a 'logit' link function? Many thanks!

aa