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 14:30:28 -0400
.
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 28 March 2014 16:54, 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.
>>
>> can anybody help?
>> Thanks
>> Pietro
>> *
>> * 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/
> *
> * 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/
*
* 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/