Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

I have a very strange problem. I don't think it's a bug because I've tried it a few ways with similar results.

I have three sets of data that are all related to each other. When I make density plots of them individually (with the sm package), like so:

sm.density(sim$V2)

I get this curve:

One of the curves individually

And the other two curves look very similar. But! When I plot them all onto one graph for comparison, I get very different results:

All the curves together

The first curve I showed you has turned into one of those shorter, jagged curves in this plot. So, I can't figure out how the first smooth curve turns into something so jagged, with apparently an extra peak appearing as well.

Does anyone have any idea what might account for this? Could there be some difference in how the density is being calculated?

share|improve this question
2  
It may be easier for people to help you if you provide a reproducible example that others can run themselves that illustrates this behavior. – joran Aug 21 '11 at 1:39

1 Answer

The sm.density function picks a smoothing parameter for you, unless you specify one. It seems like it chose different smoothing parameters for the different variables.

Try setting h to some fixed value. e.g.

sm.density(sim$v2, h = 1)

for each graph

share|improve this answer
1  
Agreed, and since the blue curve is so different from other two, I imagine the smoothing parameter choice is difficult to get right. What smooths the smaller curves might mush the taller curve entirely. – Wayne Aug 21 '11 at 15:15
1  
I suspect this is the source of the problem as well - an automatic process choosing the smoothing parameter, and choosing a different one in each case. I agree that you should try fixing the smoothing parameter and rerunning the plots. – EpiGrad Aug 22 '11 at 1:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.