Density of a (conditional) multivariate normal variate
dcmvnorm.RdDensity of a (conditional) multivariate normal variate
Usage
dcmvnorm(x, mean = 0, V = 1, keep=1, cond=(1:length(x))[-keep], log=FALSE)Author
Jarrod Hadfield j.hadfield@ed.ac.uk
Examples
V1<-cbind(c(1,0.5), c(0.5,1))
dcmvnorm(c(0,2), c(0,0), V=V1, keep=1, cond=2)
#> [1] 0.2365101
# density of x[1]=0 conditional on x[2]=2 given
# x ~ MVN(c(0,0), V1)
dcmvnorm(c(0,2), c(0,0), V=V1, keep=1, cond=NULL)
#> [1] 0.3989423
# density of x[1]=0 marginal to x[2]
dnorm(0,0,1)
#> [1] 0.3989423
# same as univariate density
V2<-diag(2)
dcmvnorm(c(0,2), c(0,0), V=V2, keep=1, cond=2)
#> [1] 0.3989423
# density of x[1]=0 conditional on x[2]=2 given
# x ~ MVN(c(0,0), V2)
dnorm(0,0,1)
#> [1] 0.3989423
# same as univariate density because V2 is diagonal