function pos = eval_pos(data,y0,covs,impsam,sk)

%_____________________________________________________________________________________________________
[tt nunits]=size(data);
L=size(impsam.la,1);
P=size(covs,1);
K=size(impsam.al,2);
pos.llik=NaN(L,1); pos.lpri=pos.llik;
li=sum(~isnan(data)); 
covs(:,1,:)=[]; 
%_____________________________________________________________________________________________________
% hyperpars
sbet=2.9645e-005; hloc=0.03; csq=0.05^2;
mulo=0;  mupre=1; rr=2; qq=0.11;
%_____________________________________________________________________________________________________
for l=1:L
    if K==1
        ca=impsam.al(l); caa=impsam.aal(l); cba=impsam.bal(l);
    else
        ca=impsam.al(l,:); caa=impsam.aal(l,:); cba=impsam.bal(l,:);
    end
    cl=impsam.la(l); 
    if sk==1
        cg=impsam.ga(l); 
    else
        cg=1;
    end
    cn=impsam.df(l); cht=impsam.ht(l);  cb=impsam.be(l,:); chmp=impsam.hmp(l); chb=impsam.hb(l); yy0=y0(l,:);
    if P>1
        cm=impsam.mu(l,:); chm=impsam.hmu(l,:);
    else
        cm=impsam.mu(l); chm=impsam.hmu(l);
    end
    ll=0; 
%_____________________________________________________________________________________________________
%Likelihood bit
    for i=1:nunits
        whos=~isnan(data(:,i));
        dati=data(whos,i);
        dat0=[yy0(i);dati(1:li(i)-1)];
        covi=squeeze(covs(:,whos,i));
        ker=dati - ca.*dat0 - (1-ca).*(cm*covi)'- (1-ca).*cb(i) ;
        ll = ll + sum(lskt(ker,cg,cl,cn));
    end
    pos.llik(l)=ll;
%_____________________________________________________________________________________________________
%Prior bit
    prila=-log(cl);
    pribe=pdf_mvn(cb,chb,cht,2);
    prita=pdf_gd(cht,2,sbet);
    prihb=pdf_nor(chb,hloc,csq,1);
    pridf=pdf_gaga(cn,1,20,2);
    if sk==1
            priga=log(2) + log(cg) - 2*log(1+cg^2);
    else
        priga=0;
    end
    primu=pdf_mvn(cm,chm,chmp,2);
    prihmu=pdf_mvn(chm,mulo,mupre,2);
    prihmp=pdf_gaga(chmp,2,1,1);
    prial=pdf_rb(ca,caa,cba);
    priaal=pdf_gd(caa,rr,qq);
    pribal=pdf_gd(cba,rr,qq);
    priall= prila + prita + prihb + pridf + priga + primu + prihmu + prihmp + sum(prial) + sum(priaal) + sum(pribal)+ pribe ;
    pos.lpri(l) =priall;
end

pos.lik=exp(pos.llik);
pos.pri=exp(pos.lpri);