Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: Graphs, pull out random values at peak interval


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: Graphs, pull out random values at peak interval
Date   Thu, 7 Jun 2007 14:07:41 +0100

This is too difficult for me to understand without
knowing more about your data or what you mean by "this order". 

My earlier solution was over-elaborate. 

by group, sort : egen maxtime = max(time)
by group : egen mintime = min(time)
gen middletime = floor((mintime + maxtime) / 2)
gen byte select = inrange(time, middletime - 12, middletime + 12)

can be slimmed to 

by group (time), sort : gen middletime = floor((time[1] + time[_N]) / 2)
gen byte select = inrange(time, middletime - 12, middletime + 12)

Nick 
[email protected] 

Knag Anne-Christine
 
> Thank you Mr Cox! I have another question regarding graphs. I 
> want to make
> twoway bar graphs showing production of the different types 
> over a period of
> time. I created the plots like this:
> 
>  twoway (bar production day_of_prod), ytitle(Production) xtitle(Day of
> production) by(type)
> 
> I have ordered the type, how can I sort the plots in this order?
> 
> I tried to simply:
> twoway (bar fec_div_div day_of_spawning), ytitle(Fecundity 
> *10-6) xtitle(Day
> of spawning) by (treat, sort(order))
> But this does not work..
> 
> I would also like to have a last summarizing showing total 
> production (all
> types together). How can I add this in the syntax?
> 
 On 6/6/07 9:05 PM, "Nick Cox" <[email protected]> wrote:
> 
> > I don't see where the randomness enters in that
> > case. Perhaps you just want 25 in the middle
> > of each panel. 
> > 
> > In that case, there are numerous slight variations
> > on this recipe: 
> > 
> > by group, sort : egen maxtime = max(time)
> > by group : egen mintime = min(time)
> > gen middletime = floor((mintime + maxtime) / 2)
> > gen byte select = inrange(time, middletime - 12, middletime + 12)
> > 
> > 

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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