Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
I saw that you had a discussion about this exact issue in here [https://github.com//issues/107] but I am still having same issues.
First of all I am modeling a cov matrix using:
Then I found your post trying to avoid cholesky for a mvNormal using this cov matrix by doing:
To complicate mine, i have different
Finally, I try to pass this to greta distribution as:
But I get the error message:
I know for sure I am doing many things wrong here since the parameters cannot converge!
My questions will be:
Your guidance and answers will be very valuable.
The error is unsurprising, as the object on the right hand side of
If you observe the variable (
There is still a computational benefit (and reduction in numerical issues) to avoiding an extra Cholesky decomposition though, so I'm assuming you want to work with the Cholesky factor for that reason. If not (and there's no point playing with Cholesky factors unless
If you really do need to skip the additional Cholesky factorisation that
# get some internal greta functions as.greta_array <- .internals$greta_arrays$as.greta_array get_node <- .internals$greta_arrays$get_node chol_to_symmetric <- .internals$utils$greta_array_operations$chol_to_symmetric # fake data n_dim <- 5 n_obs <- 10 Y <- matrix(rnorm(n_obs * n_dim), n_obs, n_dim) # parameters sds <- normal(0, 1, dim = n_dim, truncation = c(0, Inf)) correl <- lkj_correlation(dimension = n_dim, eta = 1) mu <- zeros(n_obs, n_dim) # hack to find the cholesky factor representation correl_U <- as.greta_array(get_node(correl)$representations$cholesky) # convert to covariance on the cholesky scale Sigma_U <- sweep(correl_U, 2, sds, '*') # convert back from cholesky representation to a symmetric matrix Sigma <- chol_to_symmetric(Sigma_U) # use in likelihood distribution(Y) <- multivariate_normal(mu, Sigma)
This obviously uses some internal functions. Ideally we could use the representations approach to hide this computational trick from the user. That would probably require us to add
Hi @goldingn, one more question...
How do I obtain the inverse of this Sigma_U matrix
When I try chol2inv(), I get an error downstream that it cannot be converted to greta_array cos of infinite values.
I am trying to use it in an operation to simulate from MvNormal using the precision matrix where:
Sigma_A is a very large dense matrix and I do not want to use the multivariate_normal () for it.
I tested and I think it's not a general issue.
I solved it by using
For a fake data example I tested