
HData<-list(A=matA,NrDM=NrDM,NrQ=NrQ,D=matD,B=matB,x=c(0,.2,.5,1))
#--!!-- A and B are not in cumulative form here!!
HInits<-list(list(beta=1,L=2,P=.5))
HVarsImportant<-c("beta","P","L","RP")
bugsData(HData,"HData.txt")
bugsInits(HInits);

fModel<- function(){
    #ref.point - ind specific
    #los aver  - common
    #utility   - linear
    #weighting - common prelec
    beta ~ dnorm(0,1.0E-3)
    Wa ~ dgamma(0.001, 0.001)
    L~dnorm(0,1.0E-3) %_% I(0,)
    P[1:4] ~ ddirch(prP[])
    for( dm in 1 : NrDM ){
        RP[dm]~dcat(P[])
        for( q in 1 : NrQ ){
            for(i in 2:5){
                VA[dm,q,i-1]<-(step(i-1.01-RP[dm])*(L*(x[RP[dm]]-x[i-1])*
                                                   (exp(-pow(-log(1-A[q,i-1]),W
a))-exp(-pow(-log(1-A[q,i]),Wa))))+
                               step(RP[dm]-i-1.01)*((x[RP[dm]]-x[i-1])*
                                                   (exp(-pow(-log(A[q,i]),Wa))-
exp(-pow(-log(A[q,i-1]),Wa)))))
