dcmvnorm: Density of a (conditional) multivariate normal variate

Description Usage Arguments Value Author(s) Examples

Description

Density of a (conditional) multivariate normal variate

Usage

1
dcmvnorm(x, mean = 0, V = 1, keep=1, cond=(1:length(x))[-keep], log=FALSE)

Arguments

x

vector of observations

mean

vector of means

V

covariance matrix

keep

vector of integers: observations for which density is required

cond

vector of integers: observations to condition on

log

if TRUE, density p is given as log(p)

Value

numeric

Author(s)

Jarrod Hadfield [email protected]

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
V1<-cbind(c(1,0.5), c(0.5,1))
dcmvnorm(c(0,2), c(0,0), V=V1, keep=1, cond=2)
# 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)
# density of x[1]=0 marginal to x[2] 
dnorm(0,0,1)
# same as univariate density 

V2<-diag(2)
dcmvnorm(c(0,2), c(0,0), V=V2, keep=1, cond=2)
# density of x[1]=0 conditional on x[2]=2 given 
# x ~ MVN(c(0,0), V2) 
dnorm(0,0,1)
# same as univariate density because V2 is diagonal

Example output

Loading required package: Matrix
Loading required package: coda
Loading required package: ape
[1] 0.2365101
[1] 0.3989423
[1] 0.3989423
[1] 0.3989423
[1] 0.3989423

MCMCglmm documentation built on May 2, 2019, 2:51 p.m.