Print

Print


Dear Bugs users,

Has someone an example using the dirichlet distribution in the modele,
in a case similar to a problem of compositional data ?

I couldn't find any example in the documentation. The question was
already asked in october 98, but i found no answer in the Web.

I want to model budget share (that sum to 1), but i didn't suceed
in the codes i tried. The best i could do is succeding in the compilation,
but BUGS stops at the update step without any message. I suspect
there is a problem in the definition of the parameter of dirichlet
distribution, which are not the budget share. But maybe this isn't
the main problem.

I include the code i tried.  I'll appreciate a lot any suggestion.


Best regards,

Claire Chabanet                                 
INRA - Laboratoire de Recherches sur les Aromes 
17 rue SULLY, BV1540                            
21034 DIJON cedex  FRANCE

email : [log in to unmask]


model mod4;
const
 M=128,
 T=3,   # number of orders
 S=123, # number of consumers
 P=6,   # number of products
 px.maxi=30, 
 nhi.mini=0;
var
 w[S,T,P],
 wstar[S,T,P],
 alpha[S,T,P],
 beta[S], 
 ibeta[S],
 betacat[S,M], 
 gamma[S],
 igamma[S],
 gammacat[S,M],
 condition[S,T,P],
 denom[S,T],
 denomin[S,T,P],
 nhi[S,P],
 px[S,T,P];
data  in "d1.dat";
{for (s in 1:S)
 {for (t in 1:T)
  {
   w[s,t,]~ddirch(alpha[s,t,])
   for (p in 1:P)
   {condition[s,t,p]<-step(px.maxi-px[s,t,p])*step(nhi[s,p]-nhi.mini);
   denomin[s,t,p]<-condition[s,t,p]*pow(nhi[s,p],beta[s])*pow(px[s,t,p],gamma[s])}
   denom[s,t]<-sum(denomin[s,t,]);
   for (p in 1:P)
    {wstar[s,t,p]<-condition[s,t,p]*pow(nhi[s,p],beta[s])*pow(px[s,t,p],gamma[s])/denom[s,t];
# I tried :
     alpha[s,t,p]<-wstar[s,t,p]
     alpha[s,t,p]<-wstar[s,t,p]*P # stopping during update, without message
#    alpha[s,t,p]<-wstar[s,t,p]*sum(alpha[s,t,]) # Generating code. Segmentation Fault - core dumped
    }
}

# discretiser beta (sinon, msg "Unable to choose update method for node")
ibeta[s]~ dcat(betacat[s,]);
beta[s]<-(ibeta[s]/M-0.5)*4;
for (i in 1:M) {betacat[s,i]<-1/M} # equal prior pour les beta

# discretiser gamma
igamma[s]~ dcat(gammacat[s,]);
gamma[s]<-(igamma[s]/M-0.5)*4;
for (i in 1:M) {gammacat[s,i]<-1/M} # equal prior pour les gamma
}

# prior
#px.maxi~dunif(0,30);
#nhi.mini~dunif(0,10);
}


Parsing model declarations.
Loading data value file(s).
Parsing model specification.
Checking model graph for directed cycles.
Generating code.
Generating sampling distributions.
Generating initial values
Checking model specification.
Choosing update methods.
compilation took  00:00:03 
Bugs>update(1)
      time for > 



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%