Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: AW: why is this graph all over the place?


From   Nirina F <[email protected]>
To   [email protected]
Subject   Re: st: AW: why is this graph all over the place?
Date   Mon, 21 Sep 2009 18:59:50 -0400

it is wierd because it does not show anything when I put di A[1,2]
though the following you gave still works perfectly.  I just changed
the main equation prob for etc... with my own equation and then mpg
with varmain but I dont' understand why I dont get anything in the
marg but just one zero.

       sysuse auto, clear
       prob for price mpg rep78 /*
       */  headroom trunk weight

       ins mpg
       loc uniq= r(N_unique)

       su mpg, mean
       prgen mpg, from(`r(min)')  /*
       */ to(`r(max)') /*
       */ gen(prob) n(`uniq')


       levelsof mpg

       loc i 1
       gen marg=0

       foreach level in `r(levels)'{
               mfx, var(mpg) at(mpg=`level')
               mat A = e(Xmfx_dydx)
di A[1,2]
               replace marg=A[1,2] in `i'
               loc ++i
       }



       tw (connected probp1 probx), /*
       */ xti("Mpg") ytit("Probability") /*
       */ name(prob, replace) nodraw

       tw (connected marg probx), /*
       */ xti("Mpg") ytit("Marginal Effect") /*
       */ name(marginal, replace) nodraw


gr combine prob marginal


N

On Mon, Sep 21, 2009 at 4:48 PM, Martin Weiss <[email protected]> wrote:
>
> <>
>
> -set trace on- just before you start cycling through the loop and watch for
> anything unusual. You could also put
>
>
> *************
> di A[1,2]
> *************
>
> inside the loop to see what it actually returns.
>
> HTH
> Martin
>
>
> -----Ursprüngliche Nachricht-----
> Von: [email protected]
> [mailto:[email protected]] Im Auftrag von Nirina F
> Gesendet: Montag, 21. September 2009 22:44
> An: [email protected]
> Betreff: Re: st: AW: why is this graph all over the place?
>
> No you are right, it is in  [1,2].
> I put it back to [1,2].
> But I don't understand why I don't get the value of the marginal
> effects. all I get is:
>  tab marg
>
>       marg |      Freq.     Percent        Cum.
> ------------+-----------------------------------
>          0 |      4,119      100.00      100.00
> ------------+-----------------------------------
>      Total |      4,119      100.00
>
>
>
>
>
> *
> *   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index