Models - type 5: each team has a 'consistency' assumes poisson rates in each game between two teams may differ with fluctuations described by parameters "c" (Gamma distribution). (Positive correlation in flucns) ss->logprior = 0.0 ; for ( i = 1 ; i <= ss->k ; i++ ) ss->logprior -= ((x[i]-mu[i])*(x[i]-mu[i]) ) * alpha[i] * 0.5 ; for ( g = 1 ; g <= ss->G ; g ++ ) { t1 = s[g][1] ; s1 = (double) s[g][2] ; /* 1 is at HOME */ t2 = s[g][3] ; s2 = (double) s[g][4] ; stot = s1 + s2 ; ... lt = log(time) ; lambda1 = time * exp ( ho[t1] - ad[t2] ) ; lambda2 = time * exp ( ao[t2] - hd[t1] ) ; ll1 = lt + ( ho[t1] - ad[t2] ) ; ll2 = lt + ( ao[t2] - hd[t1] ) ; lc1 = logc[t1] ; lc2 = logc[t2] ; lc = lc1+lc2 ; c = exp(lc) ; ssc = stot + c ; llc = lambda1 + lambda2 + c ; thisf = s1 * ll1 ; thisf += s2 * ll2 ; thisf += gammln (ssc) - gammln(c) + c * lc - ssc * log(llc) ; f += w * thisf ; } ss->loglike = f ; f += ss->logprior ;