Statalist


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

RE: AW: st: RE: Graphing time on the x axis


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: AW: st: RE: Graphing time on the x axis
Date   Tue, 22 Dec 2009 11:48:20 -0000

As I understand it, you have subtracted one date-time from another, but the result is not itself a date-time. It is an elapsed time, and Stata lacks any support specific to elapsed times. So, for example, 1 (elapsed) day and 2 (elapsed) days look identical in terms of clock time, as you already know. 

. di %tc_HH:MM:SS  24 * 60 * 60 * 1000
 00:00:00

. di %tc_HH:MM:SS  48 * 60 * 60 * 1000
 00:00:00

Conversely, the difference between 21 December 2009 and 22 December 2009 is not as indicated by 

. di %d mdy(12,22,2009) - mdy(12,21,2009)
02jan1960

But just 1 day. 

In short, applying date-time formats to elapsed times at best tells only  part of the story and at worst gives you nonsense. That shouldn't be a surprise when you think about it. 

For elapsed times, you need to create your own code (setting aside earlier user-written efforts best consigned to history). 

In essence, Stata carries no knowledge forward of how your variables were calculated. As I guessed earlier in the thread, you assigned a format that is no use for graphing, as it does not distinguish elapsed times except in terms of what a clock would show. 

I asked earlier for you to -summarize- the values of your variables, but I've not seen any results. From your graph it seems that the data fall into two distinct subsets, times less than 1 day and times more than 1 day. I can't suggest why that is, but only looking at your data closely can tell you if there is some error or this does in fact make sense. 

As I suggested earlier, it is likely that you need to create your own axis labels, using a conversion from milliseconds to hours.  -mylabels- from SSC is there to help. 

Nick 
n.j.cox@durham.ac.uk 

moleps islon

The measurements have taken place at -clock-. However trying to twoway
graph with clock along the x axis resulted in the problem with
changing dates and jumps on the graph. I tried to cricumvent this by
subtracting clock with the first clock-value.. but as you see it
leaves me with the same problem. I´m sure there is someway around
this...



.format x %9.0g

. l x clock in 1/5

     +------------------+
     |     x     clock |
     |------------------|
  1. |     0   18:46:46 |
  2. | 18000   18:47:04 |
  3. | 30000   18:47:16 |
  4. | 36000   18:47:22 |
  5. | 66000   18:47:52 |
     +------------------+

M




On Mon, Dec 21, 2009 at 9:58 PM, Martin Weiss <martin.weiss1@gmx.de> wrote:
>
> <>
>
> I am not sure why you - format x %td_HH:MM:SS- while I formatted - format x
> %tc_HH:MM:SS-. What happens when you
>
> ***
> format x %9.0g
> l in 1/5
> ***
>
>
> HTH
> Martin
>
>
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of moleps
> Sent: Montag, 21. Dezember 2009 21:51
> To: statalist@hsphsun2.harvard.edu
> Subject: Re: AW: st: RE: Graphing time on the x axis
>
> To me there doesnt seem to be any difference between the sets, but doing the
> following explains why the graph looks as it does. However I do not
> understand how this comes about or how I can rectify it...
>
>
>
> . list x in 1/5
>
>     +----------+
>     |        x |
>     |----------|
>  1. | 00:00:00 |
>  2. | 00:00:18 |
>  3. | 00:00:30 |
>  4. | 00:00:36 |
>  5. | 00:01:06 |
>     +----------+
>
> . sort x
>
> . list x in 1/5
>
>     +----------+
>     |        x |
>     |----------|
>  1. | 05:10:24 |
>  2. | 05:10:30 |
>  3. | 05:10:36 |
>  4. | 05:10:42 |
>  5. | 05:10:48 |
>     +----------+
>
>
> M
>
>
>
> On 21. des. 2009, at 21.18, Martin Weiss wrote:
>
>>
>> <>
>>
>> How is your dataset different from the one I am playing with?
>>
>>
>> *******
>> clear*
>> set obs 1000
>> set seed 10234
>>
>> gen x=(_n-1)*6000
>>
>> format x %tc_HH:MM:SS
>>
>> gen mean_amp =rnormal()
>> gen meanp =rnormal()
>>
>> gen byte c7=(runiform()<.2)+1
>>
>> compress
>>
>> tw (line mean_amp x if c7==1) /*
>> */ (line mean_amp x if c7==2) /*
>> */ (line meanp x if c7==1)  /*
>> */ (line meanp x if c7==2)
>> *******
>>
>>
>> HTH
>> Martin
>>
>> -----Original Message-----
>> From: owner-statalist@hsphsun2.harvard.edu
>> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of moleps
>> Sent: Montag, 21. Dezember 2009 20:32
>> To: statalist@hsphsun2.harvard.edu
>> Subject: Re: AW: st: RE: Graphing time on the x axis
>>
>> picture of the graph
>>
>> http://www.flickr.com/photos/45805518@N04/?saved=1
>>
>> commands
>>
>>
>>
>>
>>
>> . format x %td_HH:MM:SS
>>
>> . list x in 1/5
>>
>>     +----------+
>>     |        x |
>>     |----------|
>>  1. | 00:00:00 |
>>  2. | 00:00:18 |
>>  3. | 00:00:30 |
>>  4. | 00:00:36 |
>>  5. | 00:01:06 |
>>     +----------+
>> . tw (line  mean_amp x if c7==1) (line  mean_amp x if c7==2) (line   meanp
> x
>> if c7==1) (line   meanp x
>>> if c7==2)
>>
>> Regards,
>>
>> M
>>
>>
>>
>> On 21. des. 2009, at 19.57, Martin Weiss wrote:
>>
>>>
>>> <>
>>>
>>>
>>> You should probably reproduce the problem with a dataset shipped with
>> Stata.
>>> Is the time variable numeric or string?
>>>
>>>
>>>
>>> HTH
>>> Martin
>>>
>>>
>>> -----Ursprüngliche Nachricht-----
>>> Von: owner-statalist@hsphsun2.harvard.edu
>>> [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von moleps
>>> Gesendet: Montag, 21. Dezember 2009 19:48
>>> An: statalist@hsphsun2.harvard.edu
>>> Betreff: Re: st: RE: Graphing time on the x axis
>>>
>>> Maybe I was unclear in my description of the graph, but i dont think it
> is
>> a
>>> scale or label question. The problem is that given the coordinates
> (00:00,
>>> 2.3) (05:36,1.9) (07:20,3.1) (18:58,2.9) they are not graphed in that
>> order;
>>> Instead I have (07:20,3.1) (18:58,2.9) (00:00, 2.3) (05:36,1.9) ...
>>>
>>> Regards
>>>
>>> M
>>>
>>>
>>> On 21. des. 2009, at 13.45, Nick Cox wrote:
>>>
>>>> Clearly you need to specify your own.
>>>>
>>>> A convenience tool is -mylabels- from SSC. You just need to specify the
>>> conversion from Stata's underlying scale, presumably milliseconds, to
> your
>>> desired scale, which may be hours (you don't say what you want instead).
>> See
>>> the help for more.
>>>>
>>>> Nick
>>>> n.j.cox@durham.ac.uk
>>>>
>>>> moleps islon
>>>>
>>>> I´ve created a variable, time, for two measurements that both have
>>>> been subtracted from the starting time of the measuerement so that the
>>>> two  start out with time 00:00:00 and I have measurements every 10
>>>> sec. However after doing a twoway plot the starting point is not
>>>> 00:00:00. Instead I have these tick marks and values along the x
>>>> axis:: 07:20--12:53--18:58--00:00--05:36.... Any ideas?

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index