Generating Multivariate Normal Distribution in Nimble with Fixed Unit Variances

299 views
Skip to first unread message

SIWEI PENG

unread,
Oct 13, 2023, 12:59:02 PM10/13/23
to nimble-users
Hi everyone,

I would like to generate a multivariate normal distribution in Nimble where I want to fix the variances of all dimensions to 1. I used the following code:


correl[1:Dim, 1:Dim] ~ dlkj_corr_cholesky(1, Dim)
for (n in 1:Nperson) {
  PersPar[n, 1:Dim] ~ dmnorm(mu_theta[1:Dim], cholesky = correl[1:Dim, 1:Dim], prec_param = 1)
}
Is this code correct? 

Chris Paciorek

unread,
Oct 16, 2023, 2:54:53 PM10/16/23
to SIWEI PENG, nimble-users
We have some info about this Section 5.2.4.1.2 of the manual. That section shows what to do if you want a covariance. For a correlation, just leave out the multiplication by `sds`. As seen in the manual you should have `prec_param=0` if you are on the correlation or covariance scale (rather than the precision scale).

-chris

--
You received this message because you are subscribed to the Google Groups "nimble-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nimble-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nimble-users/135bb8d1-3c03-46f7-8f09-9e11342df4d3n%40googlegroups.com.

Adam Smith

unread,
Oct 21, 2025, 12:11:19 AM (10 days ago) Oct 21
to nimble-users
FYI The link to section 5.2.4.1.2 in the manual is now at https://r-nimble.org/manual/cha-writing-models.html#lkj-distribution-for-correlation-matrices.
Reply all
Reply to author
Forward
0 new messages