# INTEGRATED OMEGA Oct. 26th, 2007



# KEY VARIABLES 

#   - M is the total number of customers

#   - h is a index for customer

#   - pa is an index for the conjoint pair (each customer was exposed to 8 pairs)

#   - p_conjoint: conjoint probabilities computed from the number of chips allocated during  

#                 each conjoint task. The [-100,100] interval was transformed into [0,1]

#   - gamma: the scaling factor  

#   - CL: the left stimulus presented at each conjoint task 

#   - CR: the right stimulus presented at each conjoint task 



model{



 # Loop around customers 

 for (h in 1:M)  



 ########################

 # CONJOINT LIKELIHOOD

 {for (pa in 1:8) # loop around pairs

    {   

    # Choice_cnj comes from data -> p>.5 is choice, p<.5 is no choice, ties are randomly broken. p_logit comes from c*omega*r

    Choice_cnj[h,pa]  ~ dbern(p_logit[h,pa])



    # Computes the logit probability of choice in conjoint considering the 2 options available at each conjoint task

    # CL is the c_kj of the left conjoint stimuli at any conjoint task. CR is the c_kj of the right conjoint 

    p_logit[h,pa]  <- exp(inprod(CL_Omega[h, pa,1:5], r[h, 1:5] )/ gamma )   / 

                    ( exp(inprod(CL_Omega[h, pa,1:5], r[h, 1:5] )/ gamma )  + exp(inprod(CR_Omega[h, pa,1:5], r[h, 1:5]) / gamma )  )

 

    # WB requires the multiplications involved in c*omega*r to be done step by step. That is what CL_Omega and CR_Omega do

    CL_Omega[h,pa,1]<- inprod(CL[h,pa,1:3], OmegaMatrix1[1:3] ) 

    CL_Omega[h,pa,2]<- inprod(CL[h,pa,1:3], OmegaMatrix2[1:3] )

    CL_Omega[h,pa,3]<- inprod(CL[h,pa,1:3], OmegaMatrix3[1:3] )

    CL_Omega[h,pa,4]<- inprod(CL[h,pa,1:3], OmegaMatrix4[1:3] )

    CL_Omega[h,pa,5]<- inprod(CL[h,pa,1:3], OmegaMatrix5[1:3] )



    CR_Omega[h,pa,1]<- inprod(CR[h,pa,1:3], OmegaMatrix1[1:3] )

    CR_Omega[h,pa,2]<- inprod(CR[h,pa,1:3], OmegaMatrix2[1:3] )

    CR_Omega[h,pa,3]<- inprod(CR[h,pa,1:3], OmegaMatrix3[1:3] )

    CR_Omega[h,pa,4]<- inprod(CR[h,pa,1:3], OmegaMatrix4[1:3] )

    CR_Omega[h,pa,5]<- inprod(CR[h,pa,1:3], OmegaMatrix5[1:3] )

   } # close conjoint pair loop



  ########################

  # CLICKSTREAM LIKELIHOOD



  # loop around clicks per respondent

  for ( click in 1: numclicks[h]) 



   # a click is a multinomial draw from probability from logit(c*Omega*r)

   {Y[h,click] ~ dcat(p[h, click,1: numoptions[h,click ]] )  



     # link loop: each respondent had a different set of links to chose from 

     for (opt in 1: numoptions[h,click]  ) {    



        # click probability is computed from c*omega * r

        p[h,click,opt ]  <- cOmegaR[h, click, opt]  / sum(cOmegaR[h, click, 1: numoptions[h,click]    ]  )



        log(cOmegaR[h,click,opt ]  ) <- inprod(COmega[choiceset[h,click], opt, morph[h], 1:5], r[h,1:5] )  }   



   } # close click loop

}# close customer loop



########################################################

# This section describe all pages in the site  



# loop around all pages

for (page in 1:  15)       

 { # loop around all morphs

   for (m in 1:8) 

   {  # loop around all links in one page within one morph

      for (option in 1:  tot_options[page , m]   )

     {   COmega[page, option, m,1]   <- inprod(c_kj[page, option, m,1:10],  OmegaMatrix1 [1:10] )   

         COmega[page, option, m,2]   <- inprod(c_kj[page, option, m,1:10],  OmegaMatrix2 [1:10] )

         COmega[page, option, m,3]   <- inprod(c_kj[page, option, m,1:10],  OmegaMatrix3 [1:10] )  

         COmega[page, option, m,4]   <- inprod(c_kj[page, option, m, 1:10], OmegaMatrix4 [1:10] )  

         COmega[page, option, m,5]   <- inprod(c_kj[page, option, m, 1:10], OmegaMatrix5 [1:10] )  

      }#close option loop 

    }# close m loop

  }# close page loop



########################################

# PRIORS ON EACH COLUMN OF OMEGA MATRIX

OmegaMatrix1[1:10]~dmnorm( mn[1:10,1] ,prec[1:10 ,1:10])# mean: MLE column 1

OmegaMatrix2[1:10]~dmnorm( mn[1:10,2], prec[1:10 ,1:10])# mean: MLE column 2  

OmegaMatrix3[1:10]~dmnorm( mn[1:10,3], prec[1:10 ,1:10])# mean: MLE column 3  

OmegaMatrix4[1:10]~dmnorm( mn[1:10,4], prec[1:10 ,1:10])# mean: MLE column 4  

OmegaMatrix5[1:10]~dmnorm( mn[1:10,5], prec[1:10 ,1:10])# mean: MLE column 5  





gamma ~ dgamma ( 0.0355344, 0.188 )





} # close model



