Multivariate Normal Log-likelihood and Score Functions for Reduced Rank Covariances
lpRR.RdComputes the log-likelihood (contributions) of interval-censored observations from multivariate normal distributions with reduced rank structure and evaluates corresponding score functions.
Arguments
- lower
vector of lower limits (one element for each dimension, \(J\) elements).
- upper
vector of upper limits (one element for each dimension, \(J\) elements).
- mean
vector of means (one element for each dimension, length is recycled to length of
lowerandupper).- B
matrix of dimension \(J \times K\).
- D
vector of \(J\) diagonal elements.
- Z
matrix of standard normal random variables, with \(K\) nrows.
- weights
optional weights.
- log.p
logical. By default, log-probabilities are returned.
Details
Evaluates the multivariate normal log-likelihood defined by mean,
B and D when the covariance is \(\Sigma = B B^\top + D\)
over boxes defined by lower and upper. Details are given
in mvtnorm::Genz_Bretz_2009, Chapter 2.3.1.
slpRR computes
the corresponding score functions with respect to lower,
upper, mean, B and D.
More details can be found in the lmvnorm_src package vignette.
Examples
J <- 6
K <- 3
B <- matrix(rnorm(J * K), nrow = J)
D <- runif(J)
S <- tcrossprod(B) + diag(D)
a <- -(2 + runif(J))
b <- 2 + runif(J)
M <- 1e4
Z <- matrix(rnorm(K * M), nrow = K)
## log-likelihood
lpRR(lower = a, upper = b, B = B, D = D, Z = Z)
#> [1] -0.9192491
## score wrt all arguments
slpRR(lower = a, upper = b, B = B, D = D, Z = Z)
#> $lower
#> [1] -0.03988543 -0.12240585 -0.17089697 -0.02782872 -0.01103652 -0.03572410
#>
#> $upper
#> [1] 0.047466928 0.136029202 0.171690296 0.034421322 0.011890107 0.009547452
#>
#> $mean
#> [1] -0.0075814980 -0.0136233552 -0.0007933255 -0.0065925984 -0.0008535898
#> [6] 0.0261766484
#>
#> $B
#> [,1] [,2] [,3]
#> [1,] 0.003603196 0.13314225 0.070729942
#> [2,] -0.233602044 0.09589090 -0.024994580
#> [3,] 0.117938557 0.08653291 -0.244982777
#> [4,] -0.038944886 -0.03972351 -0.042174926
#> [5,] 0.033221322 0.01782221 -0.016100244
#> [6,] -0.051816628 -0.01113051 -0.004687892
#>
#> $D
#> [1] -0.06482371 -0.10429223 -0.09454297 -0.05619978 -0.03794360 -0.05200137
#>