function boot = mbb(y,X,nboot,tau)


T = size(y,1);
k = size(X,2);
b = floor(T^(1/3));
m = floor(T/b);
q = T-b+1;

Bi = NaN(q,b,k+1);

for i=1:q   
    Bi(i,:,:) = [y(i:i+b-1,1),X(i:i+b-1,:)]; 
end

for i=1:nboot
    Z=[];  
    for im=1:m
        
        Z = [Z;squeeze(Bi(randi([1 q]),:,:))];
        
    end
boot(i,:) = rq(Z(:,2:end),Z(:,1),tau)';     
end