% BPEA Fall 2013: The Delcine in the U.S. Labor Share, Section IV
% Elsby, Hobijn, and Sahin
%
% This program calculates the (total) backward requirements of domestic value added
% for final demand in the U.S. economy for 1993-2010. It does so under two
% assumptions: (1) some goods and services are imported, (2) all final
% demand is domestically supplied.
%
% The difference between the results under these two assumptions can then
% is the amount of domestic value added that would have been produced under
% current factor prices and productivity levels if all imports were
% domestically supplied. It is a measure of the degree of import
% competition that a sector faces.

clc

for iYear = 1993:2010

    % Initializing the IOtables object for the year for which the
    % calculations are being done
    X = IOtables.IOYear( iYear );
    
    % Initializing the output matrices if the year is the first year
    if ( iYear == 1993 )
        
        NoInd = X.Settings.NoIndustries;
        
        VA_Out = zeros(NoInd,18);
        VA_Dom_Out = zeros(NoInd,18);     
        
    end
    
    FD = X.Matrices.InitialFD;
    [ VA , M , VA_Dom ] = X.SupplyChain.BackwardRequirements( FD , 0 );
    VA_Out(:,iYear-1992) = VA;
    VA_Dom_Out(:,iYear-1992) = VA_Dom;
    
end

