Kernel density plots in Stata

May 02, 2019

Performing a Kernel density estimation in Stata is a simple task. In particular it can be visualized by way of a kernel density plot which we will look at here:

sysuse auto, clear  
kdensity price  

Result of kernel density test

As we can see prices are not normally distributed. They have a long right tail indicating a few very high-priced vehicles, over $15000.

Kernel density plots are ofen used to illustrate differences between different subgroups within a sample or distribution by overlaying the resulting graphs on top of eachother. In Stata this can be achieved with the twoway command, which we’ll look at in a subsequent post.


Profile picture

Written by Johan Osterberg who lives and works in Gothenburg, Sweden as a developer specialized in e-commerce. Connect with me on Linkedin

2024 © Johan Osterberg