function [res]=LR(r,VaR,alpha)
  I=(r>VaR);
  T=length(r);
  vio=100*sum(I)/T;
  I_lag=I(1:end-1);
  I_adj=I(2:end);
  n01=sum((I_lag==0).*(I_adj==1));
  n00=sum((I_lag==0).*(I_adj==0));
  n10=sum((I_lag==1).*(I_adj==0));
  n11=sum((I_lag==1).*(I_adj==1));
  n=length(I_adj);
  pi01=n01/(n00+n01);
  pi11=n11/(n10+n11);
  n1=sum(I_adj);
  n0=n-n1;
  LRuc=-2*(n0*log(n*(1-alpha)/n0)+n1*log(n*alpha/n1));
  puc=1-chi2cdf(LRuc,1); 
  LRind=-2*(log((n0/n/(1-pi01))^n00*(n0/n/(1-pi11))^n10*(n1/n/pi01)^n01*(n1/n/pi11)^n11));           
  pind=1-chi2cdf(LRind,1);
  LRcc=-2*(n00*log((1-alpha)/(1-pi01))+n10*log((1-alpha)/(1-pi11))+n01*log(alpha/pi01)+n11*log(alpha/pi11));            
  pcc=1-chi2cdf(LRcc,2);
  res=[vio;puc;pind;pcc];
end

