clear all close all x = load('hist_data_no.txt'); time = x(:,1); gnp = x(:,2); c = x(:,3); g = x(:,4); inv = x(:,5); ex = x(:,6); im = x(:,7); n = length(time); lgnp = log(gnp); figure plot(time,lgnp) title('gross national product') ylabel('log') %% growth rates gnp_gr_avg = (lgnp(n) - lgnp(1))/(n-7); % gnp_gr = gnp(2:n)./gnp(1:n-1)-1; % gnp_gr_avg2 = geomean(1+gnp_gr)-1; disp('annual average gnp growth rate (1865 - 2008)') disp([gnp_gr_avg ]) %%gnp_gr_avg2]) %% shares cy_share = c./gnp; iy_share = inv./gnp; gy_share = g./gnp; nx = ex - im; nxy_share = nx./gnp; figure plot(time,[cy_share, iy_share, gy_share, nxy_share]) legend('C/Y','I/Y','G/Y','NX/Y') title('shares to gnp') sample = find(~isnan(gnp)); disp('cy_share, iy_share, gy_share, nxy_share') disp([mean(cy_share(sample)), mean(iy_share(sample)), mean(gy_share(sample)), mean(nxy_share(sample))])