function [confidencelin,reglin, se, nn] = localproj(y,d, sh, lags, hor, rpos, band) %linear projections of y on x %d: dummy vars %sh: shocks %lags %horizon %band [y,Y_lags] = VAR_str(y,0,lags); T=size(y,1); d=d(lags+1:end,:); constant=ones(T,1); % intercept %log levels of pandemic indicators x=[constant Y_lags sh d]; [r,nn]=size(x); resids=zeros(size(y,1)-1,1); for i=1:hor yy=y(1+i:end,1); % xx = x(1:end-i, 2:end); results=nwest(yy, x(1:end-i,:),i); b=results.beta; bint(:,1)=b-(results.se*band); bint(:,2)=b+(results.se*band); se(:,i)=results.se'; reglin(:,i)=b; confidencelin(:,:,i)=bint; resids(i:end,i)=results.resid; % resids(i:end,i)=stats.resid; end confidencelin=reshape(confidencelin,2*nn,hor); end