Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Truncating x-axis in kernel density


From   Stephen McKay <[email protected]>
To   [email protected]
Subject   st: Truncating x-axis in kernel density
Date   Fri, 28 Nov 2003 09:04:55 +0000

> I am plotting kernel density functions of per capita 
> household consumption for three years on the same graph.
> All three distributions are skewed to the left and have 
> very long tails extending to the right.
> I would like to truncate the x axis at a certain 
> consumption value so that the long tail is dropped and the 
> area where all the action is, stretched across so that the 
> changes are more visible.

The simplest most direct answer would be something like:

tw kdensity consume , range(0 20000) 

with whatever range seemed suitable.  In quick experiments this seems 
to give what you need - by eye it seems to display only part of the 
density, not alter its shape.  Though best to check carefully with 
manuals, etc.

Regards
Steve

> 
> Date: Thu, 27 Nov 2003 21:31:54 +0000
> From: Ramani Gunatilaka <[email protected]>
> Subject: Re: st: RE: Thanks - Truncating x-axis in kernel density
> graphs
> 
> I posted my problem last night and went off to bed, and this morning
> I have three responses. Being down under has its advantages! 
> Many thanks to Sam, Nick and Philippe for their suggestions. I will
> work on them now.
> Thanks once again,
> Ramani
> 
> [email protected] wrote:
> > An alternative to working in log and back-transform the density
> might
> > here
> > be to use an adaptive kernel density estimate (-findit akdensity-
> for 
> > files and material).
> > 
> > The following lines should get you near what you want:
> > 
> > * 1/ get -akdensity-
> > net from  http://www.stata-journal.com/software/sj3-2/
> > net install st0037
> > * 2/ estimate the density and save the coordinates
> > akdensity XXX , nograph gen(x fx)
> > * plot in the range you want
> > tw line fx x if x<ZZZ
> > 
> > Hope this helps,
> > 
> > Philippe
> > 
> > 
> > <<<<<<<<<<<>>>>>>>>>><<<<<<<<<>>>>>>>>>>
> > Philippe Van Kerm
> >  CEPS/INSTEAD
> >  BP48, L-4501 Differdange
> >  G.-D. Luxembourg
> >  [email protected]
> > <<<<<<<<<<<>>>>>>>>>><<<<<<<<<>>>>>>>>>>
> > 
> > >>>>>>>>
> > 
> > st: RE: Truncating x-axis in kernel density graphs
> > 
> > 
> > Ramani Gunatilaka
> > 
> > > I am plotting kernel density functions of per capita 
> > > household consumption for three years on the same graph.
> > > All three distributions are skewed to the left and have 
> > > very long tails extending to the right.
> > > I would like to truncate the x axis at a certain 
> > > consumption value so that the long tail is dropped and the 
> > > area where all the action is, stretched across so that the 
> > > changes are more visible.
> > > I have explored the graph scale options and Stata list 
> > > archives but couldn't find anything that related to my 
> > > particular problem. 
> > > If I were to specify a shorter range of consumption values 
> > > than the entire data set, wouldn't it distort results?
> > > Would anyone be able to advise of any alternative?
*
*   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