There were unbalanced parantheses in my code. Thanks to Kit Baum for
pointing this out! *********** cap prog drop simnorm prog simnorm, rclass vers 9.0 *construct data drop _all set obs 1000 g X2=uniform()*3 g X3=uniform()*0.5+2 g Y=uniform()>0.7 gen a = 3*invnorm(uniform())+ 5 //so mean 5, sd 3 _pctile a, p(5) loc p5 = r(r1) logit Y a X2 X3, robust mfx, predict(p) at(mean a=`p5' X2=0) mat dydxmfx = e(Xmfx_dydx) ret sca dydxmfxap5 = dydxmfx[1,1] end simulate dydxmfxap5 = r(dydxmfxap5), reps(100) : simnorm *saving("C:\data\sima.dta", replace) *********** * * 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/ |
Line for the server...
On the occasion of this thread: Is capitalization in the names of returned results really advisable? - e(Xmfx_dydx)- may be used less frequently, but I remember being bitten by -r(var)- as opposed to -r(Var)- after -summ-. What is the benefit of a capitalized "V" here? HTH Martin -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Martin Weiss Sent: Tuesday, December 02, 2008 1:28 PM To: [hidden email] Subject: st: RE: Simulation: marginal effect at the 5th percentile There were unbalanced parantheses in my code. Thanks to Kit Baum for pointing this out! *********** cap prog drop simnorm prog simnorm, rclass vers 9.0 *construct data drop _all set obs 1000 g X2=uniform()*3 g X3=uniform()*0.5+2 g Y=uniform()>0.7 gen a = 3*invnorm(uniform())+ 5 //so mean 5, sd 3 _pctile a, p(5) loc p5 = r(r1) logit Y a X2 X3, robust mfx, predict(p) at(mean a=`p5' X2=0) mat dydxmfx = e(Xmfx_dydx) ret sca dydxmfxap5 = dydxmfx[1,1] end simulate dydxmfxap5 = r(dydxmfxap5), reps(100) : simnorm *saving("C:\data\sima.dta", replace) *********** * * 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/ |
Hello all,
----- "Martin Weiss" <[hidden email]> wrote: > On the occasion of this thread: Is capitalization in the names of > returned results really advisable? - e(Xmfx_dydx)- may be used less frequently, > but I remember being bitten by -r(var)- as opposed to -r(Var)- after -sum-. > What is the benefit of a capitalized "V" here? Thank you Martin. Your code -loc ap5 = r(p5)- after -sum a, detail- works fine. Also, I really appreciate your careful looking at my code and finding about typos In fact, I got an error from -r(var)- exactly like you just told me. Well, I made all the typos here because I did not copy my code exactly from my program. I try to simplify and focus on my problem. Also, thank you Marrten for your suggestion. I will try out your suggestion next. However, Martin, I have a few questions for you, please. Your answer would help educate me about Stata programming. 1) For the 2 ways of coding, which one is faster in terms of simulating time. Also, for the first way, -r(p5)- has a specific reference to the 5th percentile from the -sum, detail- command, right? When I look at -r(r1)-, how and what would this refer to? 1st way: sum a, detail loc ap5 = r(p5) 2nd way: _pctile a, p(5) loc ap5 = r(r1) 2) I have tried to run your suggested program (copy and paste it in the do and run). I got an error saying class system failure class system failure class system failure class system failure class system failure class system failure --more-- I did -set trace on- and see a lot of red characters in many places. Also the -trace- output seems very long. I am not sure I should post it here. What would be the problem here? Thank you very much, Anupit PS I am using Stata SE 9 on Window Vista Home * * 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/ |
Line for the server...
As the data management manual says (p. 443, Stata 10), there is no real advantage over -summ, d- for -_pctile-. Mainly, it can compute percentiles other than the standard ones obtainable from -summ, d-. You did not ask for a non-standard one, so -summ, d- may serve you just as well. The manual mentions a slight speed advantage for -_pctile- which results from the fact that -summ,d- calculates redundant (for you) information like standard deviation and mean while all you want is a specific percentile. Particularly in the case where all you want is one percentile, -_pctile- should be better. -set rmsg on- to check for yourself :-) After -_pctile-, you will find the first percentile requested in -r(r1)- so the returned values are not as intuitively labelled as after -summ, d-. On the second issue, do post the code in the immediate vicinity of the problem in your code. HTH Martin -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Supnithadnaporn, Anupit Sent: Wednesday, December 03, 2008 3:02 AM To: [hidden email] Subject: Re: st: RE: RE: Simulation: marginal effect at the 5th percentile Hello all, ----- "Martin Weiss" <[hidden email]> wrote: > On the occasion of this thread: Is capitalization in the names of > returned results really advisable? - e(Xmfx_dydx)- may be used less frequently, > but I remember being bitten by -r(var)- as opposed to -r(Var)- after -sum-. > What is the benefit of a capitalized "V" here? Thank you Martin. Your code -loc ap5 = r(p5)- after -sum a, detail- works fine. Also, I really appreciate your careful looking at my code and finding about typos In fact, I got an error from -r(var)- exactly like you just told me. Well, I made all the typos here because I did not copy my code exactly from my program. I try to simplify and focus on my problem. Also, thank you Marrten for your suggestion. I will try out your suggestion next. However, Martin, I have a few questions for you, please. Your answer would help educate me about Stata programming. 1) For the 2 ways of coding, which one is faster in terms of simulating time. Also, for the first way, -r(p5)- has a specific reference to the 5th percentile from the -sum, detail- command, right? When I look at -r(r1)-, how and what would this refer to? 1st way: sum a, detail loc ap5 = r(p5) 2nd way: _pctile a, p(5) loc ap5 = r(r1) 2) I have tried to run your suggested program (copy and paste it in the do and run). I got an error saying class system failure class system failure class system failure class system failure class system failure class system failure --more-- I did -set trace on- and see a lot of red characters in many places. Also the -trace- output seems very long. I am not sure I should post it here. What would be the problem here? Thank you very much, Anupit PS I am using Stata SE 9 on Window Vista Home * * 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/ |
Free forum by Nabble | Edit this page |