Search code examples
rnormal-distribution

dnorm and dmvnorm results not matching


I noticed the substantial difference between the values returned from dmvnorm (mvtnorm package) to dnorm (baseR). Which one is the correct result and why? In case of independent normal random variables, which one should I use?

> mvtnorm::dmvnorm(rep(1,2),rep(0,2), diag(2,2))
[1] 0.04826618
> prod(dnorm(rep(1,2),0,2^2))
[1] 0.009344515

Solution

  • For dmvnorm, you specify covariance; for dnorm, you set standard deviation. So if you feed diag(2,2) to the former, you want sqrt(2) to the latter.

    prod(dnorm(rep(1,2),0,sqrt(2)))
    # [1] 0.04826618