The original question seems backwards. The purpose of the loop as
written is to create (e.g.) mindiff1_2 from mindiff1 and mindiff_2, so that far from being a problem, the prior non-existence of mindiff1_2 is expected. Perhaps the questioner meant that some of the mindiff1-mindiff15 may not exist, in which case a better syntax is (as indicated by Maarten) forval i = 1/15 { forval j = 1/15 { capture gen mindiff`i'_`j' = mindiff`i' - mindiff`j' } } Note correction of typo ``i' to `i'. Nick [hidden email] Maarten buis --- Akshay SHanker <[hidden email]> wrote: > I am running the following simple loop which i need some help with: > > forvalues i =1/15 { > forvalues j=1/15{ > gen mindiff`i'_`j' = mindiff``i' - mindiff`j' > } > } > > The problem is that not all combinations of i and j exist , so for > example mindiff1_2 may not exist. Everytime the loop goes over such a > variable, the loop terminates and thus stops running the loop over > all consecutive variables which may exist. How do i stop the loop > from terminating? see: -help capture- * * 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/ |
Dear statalists,
I have two groups of farm households in my data, say Group A and Group B. Group A used soil conservation measures while Group B did not. I have data on yield (total value product per unit area) for each groups. I used kdensity to examine whether yields on conserved plots dominates the yield on non-conserved ones. However, the kdensity graphs are crossing each other at some points and therefore, difficult to conclude. Is there any way to do it? regards Jeetendra Prakash Aryal Research Fellow Department of Economics and Resource Management Norwegian University of Life Sciences (UMB) P.B. 5003, N-1432, Aas Norway * * 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...
Why not -ttest- the means of the yields? HTH Martin _______________________ ----- Original Message ----- From: "Jeetendra Aryal" <[hidden email]> To: <[hidden email]> Sent: Monday, December 01, 2008 10:45 PM Subject: st: About stochastic dominance analysis?? > Dear statalists, > > I have two groups of farm households in my data, say Group A and Group B. > Group A used soil conservation measures while Group B did not. I have data > on yield (total value product per unit area) for each groups. I used > kdensity to examine whether yields on conserved plots dominates the yield > on non-conserved ones. However, the kdensity graphs are crossing each > other at some points and therefore, difficult to conclude. > Is there any way to do it? > > regards > > Jeetendra Prakash Aryal > Research Fellow > Department of Economics and Resource Management > Norwegian University of Life Sciences (UMB) > P.B. 5003, N-1432, Aas > Norway > > > > > * > * 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/ |
In reply to this post by Jeetendra Aryal
The -somersd- package, downloadable from SSC, measures stochastic
dominance, using confidence intervals for Somers' D or Harrell's c index. It has m.pdf manuals, which explain the theory. I hope this helps. Best wishes Roger Roger B Newson BSc MSc DPhil Lecturer in Medical Statistics Respiratory Epidemiology and Public Health Group National Heart and Lung Institute Imperial College London Royal Brompton Campus Room 33, Emmanuel Kaye Building 1B Manresa Road London SW3 6LR UNITED KINGDOM Tel: +44 (0)20 7352 8121 ext 3381 Fax: +44 (0)20 7351 8322 Email: [hidden email] Web page: http://www.imperial.ac.uk/nhli/r.newson/ Departmental Web page: http://www1.imperial.ac.uk/medicine/about/divisions/nhli/respiration/pop genetics/reph/ Opinions expressed are those of the author, not of the institution. -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Jeetendra Aryal Sent: 01 December 2008 21:45 To: '[hidden email]' Subject: st: About stochastic dominance analysis?? Dear statalists, I have two groups of farm households in my data, say Group A and Group B. Group A used soil conservation measures while Group B did not. I have data on yield (total value product per unit area) for each groups. I used kdensity to examine whether yields on conserved plots dominates the yield on non-conserved ones. However, the kdensity graphs are crossing each other at some points and therefore, difficult to conclude. Is there any way to do it? regards Jeetendra Prakash Aryal Research Fellow Department of Economics and Resource Management Norwegian University of Life Sciences (UMB) P.B. 5003, N-1432, Aas Norway * * 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/ |
In reply to this post by Martin Weiss-5
It's because I want to examine the entire density of yields instead of focusing on the mean yields.
regards, Jeetendra >-----Original Message----- >From: [hidden email] [mailto:owner- >[hidden email]] On Behalf Of Martin Weiss >Sent: Monday, December 01, 2008 10:48 PM >To: [hidden email] >Subject: st: Re: About stochastic dominance analysis?? > >Line for the server... > >Why not -ttest- the means of the yields? > >HTH >Martin >_______________________ >----- Original Message ----- >From: "Jeetendra Aryal" <[hidden email]> >To: <[hidden email]> >Sent: Monday, December 01, 2008 10:45 PM >Subject: st: About stochastic dominance analysis?? > > >> Dear statalists, >> >> I have two groups of farm households in my data, say Group A and Group >B. >> Group A used soil conservation measures while Group B did not. I have >data >> on yield (total value product per unit area) for each groups. I used >> kdensity to examine whether yields on conserved plots dominates the >yield >> on non-conserved ones. However, the kdensity graphs are crossing each >> other at some points and therefore, difficult to conclude. >> Is there any way to do it? >> >> regards >> >> Jeetendra Prakash Aryal >> Research Fellow >> Department of Economics and Resource Management >> Norwegian University of Life Sciences (UMB) >> P.B. 5003, N-1432, Aas >> Norway >> >> >> >> >> * >> * 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/ |
In reply to this post by Jeetendra Aryal
Dear Jeetendra,
I suppose that you have already ruled out that curves crossing is evidence of second-order stochastic dominance (please, see for instance STINNETT AA, MULLAHY J. Net Health Benefits: A New Framework for the Analysis of Uncertainty in Cost-Effectiveness Analysis. Medical Decision Making 1998;18 suppl:S68-S80). Kind Regards, Carlo -----Messaggio originale----- Da: [hidden email] [mailto:[hidden email]] Per conto di Jeetendra Aryal Inviato: lunedÃ¬ 1 dicembre 2008 22.45 A: '[hidden email]' Oggetto: st: About stochastic dominance analysis?? Dear statalists, I have two groups of farm households in my data, say Group A and Group B. Group A used soil conservation measures while Group B did not. I have data on yield (total value product per unit area) for each groups. I used kdensity to examine whether yields on conserved plots dominates the yield on non-conserved ones. However, the kdensity graphs are crossing each other at some points and therefore, difficult to conclude. Is there any way to do it? regards Jeetendra Prakash Aryal Research Fellow Department of Economics and Resource Management Norwegian University of Life Sciences (UMB) P.B. 5003, N-1432, Aas Norway * * 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/ |
In reply to this post by Jeetendra Aryal
There is perhaps some confusion here. Density functions must cross
somewhere, unless exceptionally they are identical. If that were not true, so that one density function was everywhere higher than another, then the densities could not both integrate over their respective supports to 1, which is absurd. So crossing in itself is expected and not in itself problematic. Jeetendra is perhaps confusing density functions with distribution functions. On the latter, and in addition to other suggestions: see -distplot- (SJ), -qplot- (SJ), -qqplot- (official Stata). Use -search- to find locations. As Jeetendra has just two subsets, -qqplot- is a good direct approach to the comparison of distribution functions. Nick [hidden email] Jeetendra Aryal I have two groups of farm households in my data, say Group A and Group B. Group A used soil conservation measures while Group B did not. I have data on yield (total value product per unit area) for each groups. I used kdensity to examine whether yields on conserved plots dominates the yield on non-conserved ones. However, the kdensity graphs are crossing each other at some points and therefore, difficult to conclude. Is there any way to do it? * * 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/ |
In reply to this post by Nick Cox
Thanks for this, this seems to work. I have an extension to the question, suppose i have the following loop:
forvalues i =1/49{ forvalues j=1/13{ forvalues k=1/49{ forvalues m =1/13{ capture gen mindiff`i'_`j'__x_`k' = min(capture diff`i'_`j'__`m'_`k') } } } } I am trying to get the min of diff for a particular i,j and k over a list of m. Now again not all diff`i'_`j'__`m'_`k' exist, so while the capture allows the loop to keep running, the min function does not work unless all the specified variables exist. Is there any way around this? I could just generate missing vars for every diff`i'_`j'__`m'_`k' but that would be about .5. million vars - not possible. Thanks again, this is very helpful! Akshay On 2/12/08 1:15 AM, "Nick Cox" <[hidden email]> wrote: > The original question seems backwards. The purpose of the loop as > written is to create (e.g.) mindiff1_2 from mindiff1 and mindiff_2, so > that far from being a problem, the prior non-existence of mindiff1_2 is > expected. Perhaps the questioner meant that some of the > mindiff1-mindiff15 may not exist, in which case a better syntax is (as > indicated by Maarten) > > forval i = 1/15 { > forval j = 1/15 { > capture gen mindiff`i'_`j' = mindiff`i' - mindiff`j' > } > } > > Note correction of typo ``i' to `i'. > > Nick > [hidden email] > > Maarten buis > > --- Akshay SHanker <[hidden email]> wrote: >> I am running the following simple loop which i need some help with: >> >> forvalues i =1/15 { >> forvalues j=1/15{ >> gen mindiff`i'_`j' = mindiff``i' - mindiff`j' >> } >> } >> >> The problem is that not all combinations of i and j exist , so for >> example mindiff1_2 may not exist. Everytime the loop goes over such a >> variable, the loop terminates and thus stops running the loop over >> all consecutive variables which may exist. How do i stop the loop >> from terminating? > > see: -help capture- > > > * > * 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/ |
I don't think this would work anyway, even without the problem of
missing data because, on each pass through the loop, there is only every one variable in the -min- function. You appear to want the minimum of up to 13 variables, is that correct? If that's the case, you don't need the m loop. The -egen- function -rowmin- will give you the minimum, excluding missing values. Try: forvalues i =1/49{ forvalues j=1/13{ forvalues k=1/49{ capture egen mindiff`i'_`j'__x_`k' = rowmin(diff`i'_`j'__*_`k') } } } ______________________________________________ Kieran McCaul MPH PhD WA Centre for Health & Ageing (M573) University of Western Australia Level 6, Ainslie House 48 Murray St Perth 6000 Phone: (08) 9224-2140 Fax: (08) 9224 8009 email: [hidden email] http://myprofile.cos.com/mccaul _______________________________________________ The fact that no one understands you doesn't make you an artist. -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Akshay SHanker Sent: Thursday, 4 December 2008 10:25 AM To: [hidden email] Subject: Re: st: STATA loop terminating over missing variables Thanks for this, this seems to work. I have an extension to the question, suppose i have the following loop: forvalues i =1/49{ forvalues j=1/13{ forvalues k=1/49{ forvalues m =1/13{ capture gen mindiff`i'_`j'__x_`k' = min(capture diff`i'_`j'__`m'_`k') } } } } I am trying to get the min of diff for a particular i,j and k over a list of m. Now again not all diff`i'_`j'__`m'_`k' exist, so while the capture allows the loop to keep running, the min function does not work unless all the specified variables exist. Is there any way around this? I could just generate missing vars for every diff`i'_`j'__`m'_`k' but that would be about .5. million vars - not possible. Thanks again, this is very helpful! Akshay On 2/12/08 1:15 AM, "Nick Cox" <[hidden email]> wrote: > The original question seems backwards. The purpose of the loop as > written is to create (e.g.) mindiff1_2 from mindiff1 and mindiff_2, so > that far from being a problem, the prior non-existence of mindiff1_2 is > expected. Perhaps the questioner meant that some of the > mindiff1-mindiff15 may not exist, in which case a better syntax is (as > indicated by Maarten) > > forval i = 1/15 { > forval j = 1/15 { > capture gen mindiff`i'_`j' = mindiff`i' - mindiff`j' > } > } > > Note correction of typo ``i' to `i'. > > Nick > [hidden email] > > Maarten buis > > --- Akshay SHanker <[hidden email]> wrote: >> I am running the following simple loop which i need some help with: >> >> forvalues i =1/15 { >> forvalues j=1/15{ >> gen mindiff`i'_`j' = mindiff``i' - mindiff`j' >> } >> } >> >> The problem is that not all combinations of i and j exist , so for >> example mindiff1_2 may not exist. Everytime the loop goes over such a >> variable, the loop terminates and thus stops running the loop over >> all consecutive variables which may exist. How do i stop the loop >> from terminating? > > see: -help capture- > > > * > * 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/ |
My gut instinct here is that the postings may reflect struggling
mightily with a data structure that is not fit for purpose. Only very rarely do I find myself writing triple loops and fourfold loops even more rarely. On the whole I'd guess this level of complexity should be avoidable. As already flagged twice, I'm speculating. More information on the data structure and what Akshay wants to do with it might well refute or confirm the speculation. Nick [hidden email] Kieran McCaul I don't think this would work anyway, even without the problem of missing data because, on each pass through the loop, there is only every one variable in the -min- function. You appear to want the minimum of up to 13 variables, is that correct? If that's the case, you don't need the m loop. The -egen- function -rowmin- will give you the minimum, excluding missing values. Try: forvalues i =1/49{ forvalues j=1/13{ forvalues k=1/49{ capture egen mindiff`i'_`j'__x_`k' = rowmin(diff`i'_`j'__*_`k') } } } Akshay SHanker Thanks for this, this seems to work. I have an extension to the question, suppose i have the following loop: forvalues i =1/49{ forvalues j=1/13{ forvalues k=1/49{ forvalues m =1/13{ capture gen mindiff`i'_`j'__x_`k' = min(capture diff`i'_`j'__`m'_`k') } } } } I am trying to get the min of diff for a particular i,j and k over a list of m. Now again not all diff`i'_`j'__`m'_`k' exist, so while the capture allows the loop to keep running, the min function does not work unless all the specified variables exist. Is there any way around this? I could just generate missing vars for every diff`i'_`j'__`m'_`k' but that would be about .5. million vars - not possible. On 2/12/08 1:15 AM, "Nick Cox" <[hidden email]> wrote: > The original question seems backwards. The purpose of the loop as > written is to create (e.g.) mindiff1_2 from mindiff1 and mindiff_2, so > that far from being a problem, the prior non-existence of mindiff1_2 is > expected. Perhaps the questioner meant that some of the > mindiff1-mindiff15 may not exist, in which case a better syntax is (as > indicated by Maarten) > > forval i = 1/15 { > forval j = 1/15 { > capture gen mindiff`i'_`j' = mindiff`i' - mindiff`j' > } > } > > Note correction of typo ``i' to `i'. > > Maarten buis > > --- Akshay SHanker <[hidden email]> wrote: >> I am running the following simple loop which i need some help with: >> >> forvalues i =1/15 { >> forvalues j=1/15{ >> gen mindiff`i'_`j' = mindiff``i' - mindiff`j' >> } >> } >> >> The problem is that not all combinations of i and j exist , so for >> example mindiff1_2 may not exist. Everytime the loop goes over such a >> variable, the loop terminates and thus stops running the loop over >> all consecutive variables which may exist. How do i stop the loop >> from terminating? > > see: -help capture- * * 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 |