function vecssr=ssr_trun(start,y,z,h,last)

% This code modifies ssr.m in Bai Perron (1998) code to accomodate the
% band spectral regression approach suggested by Yamamoto and Perron (2013)

vecssr=zeros(last,1);

for r=start+h-1:last
    l=r-start+1;
    [omega na]=selectmatreal_trun(l);
    zf=omega*z(start:r,:);
    yf=omega*y(start:r,1);
    delta=inv(zf'*zf)*zf'*yf;
    res=yf-zf*delta;
    vecssr(r,1)=res'*res;
end


