rcar_normal for sample generation

10 views
Skip to first unread message

Hanah

unread,
Nov 2, 2022, 12:40:09 PM11/2/22
to nimble-users
Hi all,

I am trying rcar_normal function to get random generation for ICAR distribution. 
I follow the example in the manual documentation:
num <- c(1, 2, 2, 1)
adj <- c(2, 1,3, 2,4, 3)
weights <- c(1, 1, 1, 1, 1, 1)

and then generate a sample by
rcar_normal(n = 1,  adj,  weights = adj/adj,  num)

but I got this error "Error in eval(quote(model[[nodes]]), parent.frame(3)) : object 'model' not found"
Could someone advise how to fix this?

Thank you very much.

Best regards,
Hanah.

Daniel Turek

unread,
Nov 2, 2022, 4:29:47 PM11/2/22
to Hanah, nimble-users
Hanah, I'm sorry for the brief response.  But the dcar_normal distribution (intrinsic, or improper CAR distribution) is not a proper distribution, and cannot be used for random generation of values.  See the comments available in help(rcar_normal) for details and more reading.

The example that I think you're looking at, also from this documentation, is used to calculate the density, not for random generation, as:

x <- c(1, 3, 3, 4)

num <- c(1, 2, 2, 1)
adj <- c(2, 1,3, 2,4, 3)
weights <- c(1, 1, 1, 1, 1, 1)
lp <- dcar_normal(x, adj, weights, num, tau = 1)

An implementation of the "random generation" function rcar_normal is only in nimble, because in some of the model initialization routines used internally by nimble, this function could be called (from within a nimble model object).  So such a function must exist, although it does not generate values from the intrinsic CAR process (which cannot be done). This also explains why it's looking for a "model" object, since this routine expects to be called from usage of a dcar_normal() prior distribution, within a model object.

Cheers,
Daniel



--
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/ad8bc5b9-49a9-49a1-8c41-4543d63f8f18n%40googlegroups.com.

Chris Paciorek

unread,
Nov 2, 2022, 8:51:53 PM11/2/22
to Hanah, nimble-users
Please also see this discussion in a GitHub issue on the nimble GitHub repository, which provides a bit of guidance on how one could write one's own code to simulate from a constrained
version of the ICAR prior.

Reply all
Reply to author
Forward
0 new messages