[R] Inverse of many small matrices
murdoch.duncan at gmail.com
Thu Apr 2 16:40:45 CEST 2015
On 02/04/2015 9:31 AM, Feng Li wrote:
> Dear all,
> I am working with a likelihood function that requires the inverse of
> many small covariance matrices for multivariate normal densities. When
> the sample size is large, this calculation is really heavy. Those
> matrices are independent but unfortunately I can hardly find a way to
> vectorize them.
> Can anyone give me a hint to speed this up? Thanks in advance!
Are you sure you need the inverses of those matrices? For example, if
you are trying to compute x^t Ainv x,
where Ainv is A inverse, the naive calculation is t(x) %*% solve(A) %*%
x, but that's likely slower and less accurate than other equivalent
ones, such as x %*% solve(A, x), and I wouldn't be surprised if there
are better ones.
More information about the R-help