[R] strange results with dmvnorm

Gabor Grothendieck ggrothendieck at myway.com
Sun Oct 31 17:53:51 CET 2004


David Pleydell <D.R.J.Pleydell <at> pgr.salford.ac.uk> writes:

: I am experiencing strange results using dmvnorm. I define a scaled distance
: matrix from the coordinates bellow and then calculate a covariance matrix 
using
: a spherical correlation function.  Then with certain combinations of
: range and sill parameters dmvnorm is returning values greater than 1.  Surely
: the results of dmvnorm should be in the interval 0:1 (or do I just nead a
: holiday?).  In addition cov.spatial and sphercov are giving different 
results. 
: Any clues as to what is happening here might just save my sanity.

Probabilities must not exceed 1 but densities can.  In fact,
the normal density will approach a delta function as the standard
deviation approaches 0.    For example, in the one dimensional
case note how the density of the standard normal at x=0 increases 
as the standard deviation decreases from 1 to .2:

R>     dnorm(0,0,5:1/5)
[1] 0.3989423 0.4986779 0.6649038 0.9973557 1.9947114

or try plotting the densities to get a visual idea:

R> matplot( sapply(5:1/5, dnorm, x = (-50):50/10, mean = 0), type = "l")




More information about the R-help mailing list