How to enter discrete data to stan model and modelling mixed posterior probability?

Hello stan users;
I am new to stan. I still can not use <I got the whole concept of stan language. However, I am in a hurry to answer one of my main questions. I am trying to model 46 nodes with almost 82 connections Bayesian belief network. The nodes variables are mixed, continuous, ordinal, and categorial. for example, " Temperature measure, how you rate temperature from 1 “cold” to 5 “hot”? “what do you wear?”
I modelled the temperature and feeling but I could not model the other data, nor the required parameter,
mathematically
P(clothLayer) = \left\{ heavy = 0.1, \\ medium = 0.2, \\ light = 0.7 \right\}
posterior probability will be
P(acceptable\_Temp| temperature, feeling, cloth layer) \sim normal(mu , sigma)
As I understand, the last line is so-called a hybrid parameter which many probabilistic languages do not deal with it. It is the reason I start learning cmdstan to deal with.
so how to model both the discrete variable (data) clothLayer? and how to model the parameter itself.

my code looks like the following.

data {
  int n;
  int temp[n]; 
  int mu;
  real sigma;
  order feeling[n];
  int clothLayer[n];
}

parameter{
  real theta;
  real acceptableTemp;
}
model {
  temp ~ normal(mu, sigma);
  feeling ~ order_logistic(theta); 
  clothLayer ~  \\ what is the line I should add here? 
  acceptableTemp ~ \\what is the line I should add here?
} 

thanks so much in advance


I don’t have extensive experience with the implementation of Bayesian Belief Networks, but as far as I understand it’s a graph of nodes given by conditional probabilities, as you describe, so as long as the parameters are continuous I believe you can string together any kind of node to create a DAG and the likelihood of the model will follow.

As a general structure, in the model block you’d list the parameters (described in the parameters or transformed parameters block) with the tilde notation specifying the priors, e.g.

theta ~ normal(m,s)
accetableTemp ~ gamma(10, 0.5)

clothLayer is listed under data, so there should be no prior associated to it, if those are your observation the likelihood should come on the right hand side of that expression [e.g. observations ~ distribution(model_prediction(parameters), other_distribution_parameters)]
feeling is also under data, so if you are fitting your model to two different kinds of data you’d have two likelihoods, but if this is another independent variable it would go somewhere else (they are like x and y in a multivariate function z=f(x,y), where the model could be a multivariate regression with some coefficients, i.e. z=f(x,y|\boldsymbol{\beta})).

This looks like a (at least visually) large model, so if it’s not clear how to wire together your DAG it may be better to start with a smaller toy example and scale up once you understand the mechanics set up your real model. I’m sure you will find examples out there and probably questions on similar models here on Discourse.

Thanks a lot @caesoma Your advice was very helpful. I could start working on it. However, as you describe, its indeed a huge model and as an inexpert, i have a million question at each step. I hope I can fully model it soon.
Thank you again.

If you don’t feel comfortable implementing the full model I suggest starting with tutorials and smaller models, eventually you’ll understand all the details, and when you don’t, feel free to ask about it here. Understanding the more subtle aspects of many models may take time, but when you do you’ll be able to scale up complex models.