"Weird" Y axis for kernel density plots

1,115 views
Skip to first unread message

Gouri Shankar Mishra

unread,
May 27, 2015, 9:28:30 PM5/27/15
to davi...@googlegroups.com
Hi All

I am trying to get a density plot of the "p" variable which ranges from 0 to around 0.6. There are 8500 observations (please see attached data file). I used both ggplot and lattice. The Y-axis of the output graphs in both the options range from 0 to 100+. Is that possible? I assume that the density is bounded by 1 - which means the Y-axis can range at most from 0 to 1. 

psplot <- ggplot(data, aes(x = p, color = flex2, fill = flex2)) + geom_density(alpha=.2) + 
  ylab("Density") + xlab("Propensity Scores") 

The output graph is also attached. 

Thanks for your help. 
data.csv
psscore.pdf

Vince S. Buffalo

unread,
May 27, 2015, 10:16:30 PM5/27/15
to davi...@googlegroups.com
If I understand you correctly — the issue here is in interpretation. The y-axis of a density curve (as long as it's not cumulative density) is not a probability, so does not need to be less than or equal to 1. Rather, the probability is the integral between an interval on the x-axis, which is the area under this curve. This post helps explain this in more depth: http://stats.stackexchange.com/questions/4220/a-probability-distribution-value-exceeding-1-is-ok

HTH,
V

--
Check out our R resources at http://www.noamross.net/davis-r-users-group.html
---
You received this message because you are subscribed to the Google Groups "Davis R Users' Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to davis-rug+...@googlegroups.com.
Visit this group at http://groups.google.com/group/davis-rug.
For more options, visit https://groups.google.com/d/optout.



--
Vince Buffalo
@vsbuffalo :: vincebuffalo.com
Coop Lab :: Population Biology Graduate Group
University of California, Davis
Reply all
Reply to author
Forward
0 new messages