https://github.com/cran/LearnBayes
Revision 3b0412e613a3efcfd5e679868e78d0a55f16cb75 authored by Jim Albert on 08 November 2008, 00:00:00 UTC, committed by Gabor Csardi on 08 November 2008, 00:00:00 UTC
1 parent b553a7c
Raw File
Tip revision: 3b0412e613a3efcfd5e679868e78d0a55f16cb75 authored by Jim Albert on 08 November 2008, 00:00:00 UTC
version 2.0
Tip revision: 3b0412e
bradley.terry.post.R
bradley.terry.post=function(theta,data)
{
N=dim(data)[1]; M=length(theta)
sigma=exp(theta[M])
logf=function(k)
{
i=data[k,1]; j=data[k,2]
p=exp(theta[i]-theta[j])/(1+exp(theta[i]-theta[j]))
data[k,3]*log(p)+data[k,4]*log(1-p)
}
sum(sapply(1:N,logf))+sum(dnorm(theta[-M],0,sigma,log=TRUE))
}
back to top