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

From |
"maurizio.pisati" <maurizio.pisati@unimib.it> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
Re: st: 3D surface plot of joint density |

Date |
Thu, 03 Sep 2009 09:19:05 +0200 |

* 1. Normalize variables in the range [0,1] sysuse "auto.dta", clear summarize price mpg clonevar x = mpg clonevar y = price replace x = (x-0) / (50-0) replace y = (y-0) / (20000-0) mylabels 0(10)50, myscale((@-0) / (50-0)) local(XLAB)

keep x y save "xy.dta", replace * 2. Generate a 100x100 grid spgrid, shape(hexagonal) xdim(100) /// xrange(0 1) yrange(0 1) /// dots replace /// cells("2D-GridCells.dta") /// points("2D-GridPoints.dta") * 3. Estimate the bivariate probability density function spkde using "2D-GridPoints.dta", /// xcoord(x) ycoord(y) /// bandwidth(fbw) fbw(0.1) dots /// saving("2D-Kde.dta", replace) * 4. Draw the density plot use "2D-Kde.dta", clear recode lambda (.=0) spmap lambda using "2D-GridCells.dta", /// id(spgrid_id) clnum(20) fcolor(Rainbow) /// ocolor(none ..) legend(off) /// point(data("xy.dta") x(x) y(y)) /// freestyle aspectratio(1) /// xtitle(" " "Mileage (mpg)") /// xlab(`XLAB') /// ytitle("Price" " ") /// ylab(`YLAB', angle(0)) Best wishes, Maurizio Pisati dgill wrote: I am trying to generate a graph of the joint density of two variables (bmi and age). I am aware of the 3 variable graphing packages such as scat3 and gr39, but those ask for 3 separate variables. I want my 3rd dimension to be the joint density, not another variable. My data are individuals followed over time. So I have their age and their body mass for each year of their life. Can anyone point me in the right direction? -Donna Gilleskie

* 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/

**Follow-Ups**:**RE: st: 3D surface plot of joint density***From:*"Mak, Timothy" <timothy.mak07@imperial.ac.uk>

- Prev by Date:
**st: R: Survival analysis for uncensored data** - Next by Date:
**st: left censoring, survival analysis** - Previous by thread:
**Re: st: 3D surface plot of joint density** - Next by thread:
**RE: st: 3D surface plot of joint density** - Index(es):

© Copyright 1996–2015 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |