Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Re: kdensity of a date


From   Austin Nichols <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Re: kdensity of a date
Date   Fri, 28 Mar 2014 20:39:44 -0400

Pietro Biroli <[email protected]> :
With upper and lower limits, you should use -kdens- as I demonstrated,
not -twoway- or -kdensity-

On Fri, Mar 28, 2014 at 6:46 PM, Pietro Biroli <[email protected]> wrote:
> Dear Austin and Nick,
>
> thank you much for your help. Using the option "xlabel" solved my problem.
> As Austin suggested, I do have natural upper and lower limits and so
> the following command solved my issue:
>
> local var Date
> sum `var', mean
> local low=r(min)
> local high=r(max)
> local step=round((`high'-`low')/5)
> twoway (kdensity `var' ), xlabel(`low'(`step')`high' , format(%td))
>
> thanks again!
> Pietro
>
>
>
>>You can save the estimates and graph using a different command.
>>But where are these dates from? Are there natural upper and lower limits?
>>Compare:
>>
>>sysuse sp500, clear
>>su date, mean
>>loc l=r(min)
>>loc h=r(max)
>>keep if open/close<1
>>kdensity date, nogr gen(d f)
>>format d %tdCCYY_Mon
>>line f d
>>cap ssc inst kdens
>>kdens date, nogr gen(g) at(d) ul(`h') ll(`l')
>>line f g d
>>
>>
> On Fri, Mar 28, 2014 at 2:26 PM, Nick Cox <[email protected]> wrote:
>> Works for me. I have to work a bit at getting _nice_ dates, but there you go.
>>
>> local dates
>> clear
>> set obs 100
>> set seed 2803
>> gen mydate = round(rnormal(19000, 100))
>>
>> forval i = 2011/2012 {
>> local dates `dates' `=mdy(1,1,`i')' `=mdy(7,1,`i')'
>> }
>> kdensity mydate, xla(`dates', format(%td_d_m_CY))
>>
>> See also
>>
>> http://www.stata-journal.com/sjpdf.html?articlenum=gr0030
>>
>> where the whole small thing is discussed in excruciating detail.
>>
>> Nick
>> [email protected]
>
> On Fri, Mar 28, 2014 at 11:54 AM, Pietro Biroli <[email protected]> wrote:
>> Dear All,
>>
>> I want to draw a kdensity plot of a date variable, but when I do so
>> the x-axis shows only numbers and not the appropriate date format
>> (%td).
>>
>> I have a variable called Date that stores the day when an event
>> occurred. The display format of the variable is %td, so that when I
>> -browse Date-, -tab Date-, or even -histogram Date- I see something
>> like 22Nov2013.
>>
>> However when I use the kdensity command, on the x-axis I see only a
>> number, notably, the number of days since 01jan1960. I tried to use
>> some options like ", format" or ", range()" but they are not accepted.
>>
>
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index