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

From |
"Martin Weiss" <martin.weiss1@gmx.de> |

To |
<statalist@hsphsun2.harvard.edu> |

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

Date |
Mon, 21 Sep 2009 22:33:15 +0200 |

<> List the matrix and come back with the result... Is "varmain" really in column 57? HTH Martin -----Ursprüngliche Nachricht----- Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Nirina F Gesendet: Montag, 21. September 2009 22:33 An: statalist@hsphsun2.harvard.edu Betreff: Re: st: AW: why is this graph all over the place? Oh, because When I did mat list e(Xmfx_dydx) I got: e(Xmfx_dydx) [1, 57] On Mon, Sep 21, 2009 at 4:26 PM, Martin Weiss <martin.weiss1@gmx.de> wrote: > > <> > > " I corrected the matrix to > replace marg=A[1,57] in `i'" > > Just give me a hint why you did that... > > You could simply pick one of the values of your varmain, and plug it into > -mfx, such as seen here for the value you mentioned earlier. Then list the > contents of the matrix with the marginal effects. > > > ************* > mfx, var(varmain) at(varmain=42.6) > mat list e(Xmfx_dydx) > ************* > > and show us the output... > > > HTH > Martin > > > -----Ursprüngliche Nachricht----- > Von: owner-statalist@hsphsun2.harvard.edu > [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Nirina F > Gesendet: Montag, 21. September 2009 22:14 > An: statalist@hsphsun2.harvard.edu > Betreff: Re: st: AW: why is this graph all over the place? > > Replacing it with -levelsof- made it work! Thanks. > But I don't know why the marginal effects are not recorded. However, I > corrected the matrix to > replace marg=A[1,57] in `i' > Thanks in advance again, > Nirina > On Mon, Sep 21, 2009 at 4:05 PM, Martin Weiss <martin.weiss1@gmx.de> wrote: >> >> <> >> >> See, just when I thought I knew Stata: -levels- is not the abbreviation > for >> -levelsof-, it is an out-of-date command, apparently with limited >> functionality. I never noticed, but you did with your non-integer value... >> So replace it by -levelsof- and it should work: >> >> >> ************* >> clear* >> inp x >> 1 >> 3 >> 4.5 >> 4 >> end >> levelsof x >> levels x >> ************* >> >> >> >> HTH >> Martin >> >> -----Ursprüngliche Nachricht----- >> Von: owner-statalist@hsphsun2.harvard.edu >> [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Nirina F >> Gesendet: Montag, 21. September 2009 21:33 >> An: statalist@hsphsun2.harvard.edu >> Betreff: Re: st: AW: why is this graph all over the place? >> >> Thank you very much Martin. >> I tried the example and it worked perfectly. When I tried with my >> variables, the one that replaces mpg has one value that is not an >> integer but is 42.6, therefore I got an error message: >> levels varmain >> varmain contains non-integer values >> r(459); >> I guess I should change the command -levels- with another one that >> could list the values of varmain. >> Also, I tried to recode varmain (42.6=43) but then I don't get >> anything inside the new variable marg that keeps the marginal effects. >> I am sure something is not right there because your example works >> perfectly. I am going through each line to check. >> >> Nirina >> >> On Thu, Sep 17, 2009 at 6:19 PM, Martin Weiss <martin.weiss1@gmx.de> > wrote: >>> >>> <> >>> >>> Try this and check it very carefully. I could not find such a picture in >>> Long and Freese (2006), http://www.stata-press.com/books/regmodcdvs.html, >> - >>> which I regard as a bad sign. >>> >>> Also note I am using the old -mfx- here, as I have not fully gotten my >> head >>> round the -margins- command. Hence the -version- statement... >>> >>> >>> ************* >>> vers 10.1 >>> >>> qui{ >>> 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') >>> >>> >>> levels mpg >>> >>> loc i 1 >>> gen marg=0 >>> >>> foreach level in `r(levels)'{ >>> mfx, var(mpg) at(mpg=`level') >>> mat A = e(Xmfx_dydx) >>> 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 >>> ************* >>> >>> >>> >>> HTH >>> Martin >>> >>> >>> -----Ursprüngliche Nachricht----- >>> Von: owner-statalist@hsphsun2.harvard.edu >>> [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Nirina F >>> Gesendet: Donnerstag, 17. September 2009 18:46 >>> An: statalist@hsphsun2.harvard.edu >>> Betreff: Re: st: AW: why is this graph all over the place? >>> >>> Dear Martin, >>> >>> Thank you very much for the clarification. >>> How about graphing the marginal effects next to that graph? >>> nrina >>> >>> On Thu, Sep 17, 2009 at 12:04 PM, Martin Weiss <martin.weiss1@gmx.de> >> wrote: >>>> >>>> <> >>>> >>>> The -prgen- command holds all other covariates at their mean by default, >>> so >>>> my code has already taken care of your concern. To change the -title-s: >>>> >>>> ************* >>>> 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') >>>> >>>> tw (connected probp1 probx), /* >>>> */ xti("Mpg") ytit("Probability") >>>> ************* >>>> >>>> >>>> >>>> HTH >>>> Martin >>>> >>>> >>>> -----Ursprüngliche Nachricht----- >>>> Von: owner-statalist@hsphsun2.harvard.edu >>>> [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Nirina F >>>> Gesendet: Donnerstag, 17. September 2009 17:55 >>>> An: statalist@hsphsun2.harvard.edu >>>> Betreff: Re: st: AW: why is this graph all over the place? >>>> >>>> Thank you very much Martin for your help. It worked so well. >>>> >>>> I have a few questions: >>>> >>>> is it possible also to graph the marginal effects of just the mpg at >>>> each value of mpg. I know if you calculate >>>> . mfx >>>> after >>>> . prob for price mpg rep78 headroom trunk weight >>>> >>>> then you get the marg. effects at the mean value but I would like the >>>> marginal effects at each value of mpg but keeping the other variables >>>> at their mean. I am aware of the -at- option but it's just difficult >>>> to graph it. >>>> >>>> Also, How would I change the name of the xaxis and yaxis of the previous >>>> graph? >>>> >>>> Thank you very much, >>>> >>>> Nrina >>>> >>>> >>>> On Thu, Sep 17, 2009 at 8:00 AM, Martin Weiss <martin.weiss1@gmx.de> >>> wrote: >>>>> >>>>> <> >>>>> >>>>> For these purposes, Scott Long`s -findit spost- comes in handy. Of >>> course, >>>>> Long and Freese (2006), >> http://www.stata-press.com/books/regmodcdvs.html, >>>> is >>>>> the canonical reference for what you are trying to achieve. Try this: >>>>> >>>>> >>>>> ************* >>>>> 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') >>>>> >>>>> tw (connected probp1 probx) >>>>> ************* >>>>> >>>>> >>>>> >>>>> HTH >>>>> Martin >>>>> >>>>> >>>>> -----Ursprüngliche Nachricht----- >>>>> Von: owner-statalist@hsphsun2.harvard.edu >>>>> [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Nirina F >>>>> Gesendet: Donnerstag, 17. September 2009 13:41 >>>>> An: statalist@hsphsun2.harvard.edu >>>>> Betreff: st: why is this graph all over the place? >>>>> >>>>> Dear all, >>>>> >>>>> I would like to graph the predicted probabilities of having foreign >>>>> against mpg in order to highlight the slope(basically the marginal >>>>> effects) at each value of mpg. >>>>> I run the following but it is all over the place because I think it is >>>>> giving me the predicted probabilities from different variables. >>>>> Could you help me in this please. also if you could help me graph the >>>>> marginal effects of mpg from this probit equation against each value >>>>> of mpg. >>>>> >>>>> probit foreign price mpg rep78 headroom trunk weight >>>>> predict pmpg, p >>>>> sort mpg >>>>> twoway line pmpg mpg >>>>> >>>>> Thank you veyr much, >>>>> N >>>>> * >>>>> * 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/ >>>>> >>>> >>>> * >>>> * 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/ >>>> >>> >>> * >>> * 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/ >>> >> >> * >> * 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/ >> > > * > * 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/ > * * 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/

**References**:**st: why is this graph all over the place?***From:*Nirina F <fstata@gmail.com>

**Re: st: AW: why is this graph all over the place?***From:*Nirina F <fstata@gmail.com>

**Re: st: AW: why is this graph all over the place?***From:*Nirina F <fstata@gmail.com>

**Re: st: AW: why is this graph all over the place?***From:*Nirina F <fstata@gmail.com>

**Re: st: AW: why is this graph all over the place?***From:*Nirina F <fstata@gmail.com>

**Re: st: AW: why is this graph all over the place?***From:*Nirina F <fstata@gmail.com>

- Prev by Date:
**Re: st: AW: why is this graph all over the place?** - Next by Date:
**Re: st: AW: why is this graph all over the place?** - Previous by thread:
**Re: st: AW: why is this graph all over the place?** - Next by thread:
**Re: st: AW: why is this graph all over the place?** - Index(es):

© Copyright 1996–2019 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |