function [loglike] = logit_two_way_lk(para,AI, BI)


global mxx;
global ID1;
global ID2;

ai=AI(ID1,1);
bi=BI(ID2,1);
%ai=para(9);
%bi=0;
x=mxx(:,1:8);
y=mxx(:,10);
%global y;
%global z;
beta=[para(1:8)];
%para(16:27)=para(2:13);


%dispersion=abs(para(10));




p=0;
% theta is a k*q matrix, q=number of classes, k=number of columns in z, here
% I assume q=3
li=0; %initialize log likelihood

      
lambda=1+exp(x*beta +ai+bi);
l1=1-1./lambda;
l0=1-l1;
p=0.0053*y.*l1+1.5632*(1-y).*l0;
li=sum(log(p));

    if(li>0)
        li=-999999;
    end
    loglike=li;
 

