Skip to content

p value for joint probability

6 messages · moleps, Nordlund, Dan (DSHS/RDA), Mike Marchywka +2 more

#
My terminology is probably way off. I?ll try again in plain english. 

I?d like  to generate a scatter plot of r1 & r2 and color code each pair according to the probability of observing the pair given that the two samples (r1 & r2) are drawn from two independent normal distributions.

rr<-data.frame(r1=-rnorm(1000,10,5),r2=-rnorm(1000,220,5))

with(rr,plot(r1,r2))

Best,
//M
On 31. jan. 2011, at 23.13, Peter Ehlers wrote:

            
#
And the answer is the same as Peter gave below.  The theoretical probability of a specific pair of numbers occurring in your example is zero.  So, I will ask Peter's question differently (although his question was a good one).  What is your interest in doing these plots?  What are you trying to understand?  Are you just trying to learn how do this "joint probability" plot for use on data where there is a non-zero probability of pairs of numbers occurring?   Equiring minds would like to know.  :-)

Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204
#
Empirically of course, the probability is not zero since it did happen :) As with the folks
surprised about floating point equality compares, there is some integration over the
quantization interval. So in fact the probabiliyt of measuring what was measured is
an integral over the floating point difference between the two closest numbers. Presumably
however you want an answer unrelated to the fp properties.
#
On Feb 1, 2011, at 2:31 PM, moleps wrote:

            
The answer is still zero. If you want to ask a different question that  
might have a non-zero answer, it might be: How can I color points on  
the basis of their joint density with an assumption of no  
correlation , you might get a better answer. Densities are not  
probabilities. You would need to specify whether the arguments to the  
rnorm functions (i.e. the theoretic values) were to be used or did you  
intend to use sample values for mean and sd?
David Winsemius, MD
West Hartford, CT
#
On Tue, Feb 01, 2011 at 08:31:57PM +0100, moleps wrote:
When you say probability, do you actually mean the density function?

  http://en.wikipedia.org/wiki/Probability_density_function

The probability that a random point belongs to a region is 
the integral of the density function over that region. If the
region is a single point, then this integral is zero.

Functions related to a multivariate normal distribution may
be computed using package

  http://cran.at.r-project.org/web/packages/mvtnorm/index.html

Petr Savicky.
#
Allright.. Appreciate the input on non-zero terminology (:-). What I wanted was:

rr<-data.frame(r1=rnorm(1000,10,5),r2=rnorm(1000,220,5))
with(rr,plot(r1,r2))
r3<-kde2d(r1,r2,lims=c(2,18,200,240))

filled.contour(r3)


//M
On 1. feb. 2011, at 21.26, David Winsemius wrote: