1
$\begingroup$

In my Hierarchical Bayesian Model, in the data layer y[i] <- M(t,u,v)+ N[0,sigma_y] where M is a complicated function. I have generated the output of this M by some numerical simulation for a large grid of parameters (t,u,v).

In order to do MCMC on this grid i need to define a function which looks up the table of the Model M's output for a given input (t,u,v).

But in OpenBUGS documentation, I could find only standard distributions like dnorm etc for defining y[i].

Isn't it possible to use a general function for it? Or, Is there any other way to do it?

Update: My model is as shown below.

$i$ represents the measured data, and $j$ represent the groups.

$y_i \sim M(t,u_{j[i]},v_{j[i]}) + \mathcal{N}[0,\sigma_i]$

In the group level, $(u_j,v_j) \sim \mathcal{N}[(\mu_{u},\mu_v), \Sigma]$

The function $M$ does not have a simple analytical form to express in Bugs. But if i can define a general function to look up a table, then for each step in MC chain, I can lookup the value of deterministic relation $M$ for a given t,u,v parameter.

My goal is to estimate, $\mu_u$, $\mu_v$,$\Sigma$ and $t$ which best fits the the given $y_i$ and $\sigma_i$ data.

I am attaching a diagram of the model below. My Sample Model

$\endgroup$

1 Answer 1

1
$\begingroup$

In your question you are assigning a value to y[i], not describing how the y's are distributed. If I understand you correctly, you want to describe the deterministic/predicted value Yhat using the function M(t,u,v), with the stochastic/sampling process determined by a normal distribution (i.e. the actual observations). This can be accomplished by:

 y[i] ~ dnorm(Yhat[i], tau.sigma_y)
 Yhat[i] <- M(t,u,v)

In more general terms:

$$y_i \sim \mathcal{N}(\hat{y}_i,\sigma^2_y) \\ \hat{y}_i = M(t,u,v)$$ You then need to feed the correct values from the function M to each observation (through Yhat), but that can be accomplished in several different ways. I don't know the specifics of your function, but as an made-up example case a function M(t,u,v) could be written as:

Yhat[i] <- exp(beta1*t[i]) - (beta2 * u[i] * abs(v[i]))/(beta3 + u[i])

Here values of u, v and t for observation i is fed to Bugs as data and the parameters beta1, beta2 and beta3 are estimated (and you need to supply initial values of these). Or do you have a function M that truly cannot be specified in Bugs?

You can also "pre-calculate" the values of M for each observation (from the t,v & u of the observation) and supply this as data to the model as:

Yhat[i] <- M[i] # or skipping this step since it's redundant 

This means that Yhat[i] is directly calculated from your simulation, and the step is redundant. You could just as well give Yhat as data (directly in Openbugs or e.g. called from R through R2Openbugs). Without knowing the exact purpose of your modelling exercise it is difficult to know what you want to accomplish with the MCMC model.

If you need more flexibility to create user-defined functions, maybe to make external calls, you should look at STAN, where I think this is possible to a larger extent (I haven't used STAN though).

$\endgroup$
13
  • $\begingroup$ Thank you for the help. That is exactly what I want to do. But my issue is how to define M(t,u,v). I cannot write it as a function of standard distributions available in BUGS. I need to write a function which reads from a pre-calculated grid of t,u,v. How do I accomplish that in BUGS? $\endgroup$
    – indiajoe
    Commented Oct 13, 2014 at 21:54
  • $\begingroup$ Do you mean that all values of M(t,v,u) are "pre-calculated" as a grid of all combinations of predictor variables? What are your predictors, and I assume that you want to estimate the effects of t, v, & u? What type of functions are hidden in M? Without this info it's hard to say what can and cannot be done in Bugs. $\endgroup$ Commented Oct 13, 2014 at 22:01
  • $\begingroup$ For each combination of parameters t,u,v; M is calculated using a complicated computer simulation. (It is basically a radiation transfer code). This is calculated already on a cluster machine for a grid of t,u and v. So I was planning to run MCMC on this grid. I can use some interpolation to find M(t,u,v) for each (t,u,v) in the MC chain. But for this i need to define a function which does that in OpenBUGS. $\endgroup$
    – indiajoe
    Commented Oct 13, 2014 at 22:24
  • $\begingroup$ @indiajoe You can always just give the output of M as data (basically giving yhat for each observation), and e.g. estimate sigma_y and evaluate the fit of the model. However, from my perspective, you usually want to estimate effects of t,u and v which you cannot do (from what I know) if you only supply a given output of M. What is the desired "outcome" of your MCMC model (i.e. what effects and model features do you want to evaluate)? $\endgroup$ Commented Oct 13, 2014 at 22:31
  • $\begingroup$ I have measurements y . which i need to fit with M to find the t,u and v. It is Hierarchical parameter estimation because my y data is grouped, and some of the parameter in M are group specific. $\endgroup$
    – indiajoe
    Commented Oct 13, 2014 at 22:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.