Extracting informations on parents from greta_array

As mentioned here, I’d like to get the log-likelihoods of the response based on the posterior draws of the model parameters in order to get loo working for greta models.

Say that we have the following simple lm:

intercept <- normal(0, 1)
slope <- normal(0, 1)
sd_resid <- cauchy(0, 1, truncation = c(0, Inf))
   
x <- runif(100)
y <- as_data(rnorm(100, 1 + 2 * x, 1))
  
linpred <- intercept + slope * x

distribution(y) <- normal(linpred, sd_resid)

Is there a way to grasp from the y object the following:

  • the distribution
  • all direct parents objects

The aim would be to get a function like @nick suggested:

loglik <- density(y, log = TRUE)

Given that I never worked with R6 classes before some pointers would be much appreciated :slight_smile: