function F = news_max_seven(x2)

global IRF TOT h hh

for j = 1:hh
    INFOS(:,j) = [IRF(1,j) IRF(8,j) IRF(15,j) IRF(22,j) IRF(29,j) IRF(36,j) IRF(43,j)]*x2'; % Calculates responses to modified shock
end

INFO2 = INFOS.^2; % squares everything

INFO2S = cumsum(INFO2); % cumulates the sums


for j = 1:h
DD(1,j) = INFO2S(1,j)/TOT(j,1);
end % This calculates fraction of total variance due to news at each horizon

F = -sum(DD); % objective function is the sum

% alternatively, can specify objective function as FEVD at a particular
% horizon

%F = - DD(1,hh);