Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
99 lines (79 sloc) 2.67 KB
xls = xlsread('data.xls');
time = 1:399;
real_time = 1979 + time/12;
time_adjust = 1:200;
time_test = 201:399;
data = xls(time,1:39);
oil = data(:,1); % íåôòü
gold = data(:,2); % çîëîòî
iron = data(:,3); % æåëåçíàÿ ðóäà
logs = data(:,4); % áðåâíî
maize = data(:,5); % êóêóðóçà
beef = data(:,6); % ãîâÿäèíà
chicken = data(:,7); % êóðèöà
gas = data(:,8); % ïðèðîäíûé ãàç
liquid_gas = data(:,9); % ñæèæåííûé ãàç
tea = data(:,10); % ÷àé
tobacco = data(:,11); % òàáàê
wheat = data(:,12); % ïøåíèöà
sugar = data(:,13); % ñàõàð
soy = data(:,14); % ñîÿ
silver = data(:,15); % ñåðåáðî
rice = data(:,16); % ðèñ
platinum = data(:,17); % ïëàòèíà
cotton = data(:,18); % õëîïîê
copper = data(:,19); % ìåäü
coffee = data(:,20); % êîôå
coal = data(:,21); % óãîëü
aluminum = data(:,22); % àëþìèíèé
bananas = data(:,23); % áàíàíû
barley = data(:,24); % ÿ÷ìåíü
cocoa = data(:,25); % êàêàî
coconut_oil = data(:,26); % êîêîñîâîå ìàñëî
groundnut_oil = data(:,27); % àðàõèñîâîå ìàñëî
lead = data(:,28); % ñâèíåö
sheep_meat = data(:,29); % áàðàíèíà
nickel = data(:,30); % íèêåëü
oranges = data(:,31); % àïåëüñèíû
palm_oil = data(:,32); % ïàëüìîâîå ìàñëî
shrimp = data(:,33); % êðåâåòêè
soybean_meal = data(:,34); % ñîåâûé øðîò
soybean_oil = data(:,35); % ñîåâîå ìàñëî
steel_rebar = data(:,36); % ñòàëüíàÿ àðìàòóðà
tin = data(:,37); % îëîâî
woodpulp = data(:,38); % öåëëþëîçà
zinc = data(:,39); % öèíê
all_goods = [oil gold logs maize beef chicken gas tea tobacco wheat sugar soy rice cotton copper coffee coal];
goods_count = size(all_goods, 2);
geom_average = ones(size(time))';
for i = 1:goods_count
geom_average = geom_average .* all_goods(:,i);
end
geom_average = geom_average .^ (1/goods_count);
all_goods_rel = zeros(size(all_goods));
all_goods_norm = zeros(size(all_goods));
mean_ = zeros(1,goods_count);
std_ = zeros(1,goods_count);
percent_std_ = zeros(1,goods_count);
for i = 1:goods_count
all_goods_rel(:,i) = all_goods(:,i) ./ geom_average;
mean_(i) = mean(all_goods_rel(:,i));
all_goods_norm(:,i) = all_goods_rel(:,i) / mean_(i);
std_(i) = std(all_goods_rel(:,i));
percent_std_(i) = 100*std_(i)/mean_(i);
end
A = cov(all_goods_rel(time_adjust,:));
cond = ones(1, goods_count);
B = [2*A cond'];
B = [B; [cond 0]];
b = [zeros(1, goods_count) 1]';
x = (B^-1)*b;
DP = all_goods_rel*x(1:goods_count);
figure;
plot(real_time(time_test), DP(time_test)'/mean(DP(time_test)));
axis([real_time(time_test(1)) real_time(time_test(end)) 0.8 1.2]);
DP_mean = mean(DP(time_test))
DP_std = std(DP(time_test))
DP_percent_std = 100*DP_std/DP_mean
DP_min = min(DP(time_test))/DP_mean
DP_max = max(DP(time_test))/DP_mean
You can’t perform that action at this time.