📜 ⬆️ ⬇️

Money, goods and some statistics. Part two

In the first part of the article I wrote about the statistical processing of data on the prices of goods for more than 30 years.
Here I will try to track the relationship between individual products.
To be more precise, under the cut a bit of matlab-code and image graphs.

First, we load the data and calculate relative prices (more about this in the first part of the article):

xls = xlsread('data.xls'); time = 1:399; data = xls(time,1:22); oil = data(:,1); gold = data(:,2); iron = data(:,3); logs = data(:,4); %    all_goods = [oil gold iron logs maize beef chicken gas liquid_gas tea tobacco wheat sugar soy silver rice platinum cotton copper coffee coal aluminum]; %  ,     : ids = {'oil','gold','iron','logs','maize','beef','chicken','liquid_gas','gas','tea','tobacco','wheat','sugar','soy','silver','rice','platinum','cotton','copper','coffee','coal','aluminum'}; 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)); for i = 1:goods_count all_goods_rel(:,i) = all_goods(:,i) ./ geom_average; end 


Next, we calculate the matrix of correlation coefficients:
')
 R = corrcoef(all_goods_rel); 


Now you can build a graph:

 %  : threshold = 0.25; % 0.33 0.4 0.45 0.55 0.6 0.65 0.7 %   : links = R>threshold; % ,  : bg = biograph(links, ids); view(bg); 


results



With a correlation threshold of 25%, we see a rather complex system of interconnections:



With a threshold of 33%, the goods fall into 2 large groups:
1. Oil, coal, gas, liquefied gas, iron ore, platinum, gold, silver and copper.
2. Aluminum, logs, chicken, tea, tobacco, cotton, coffee, rice, sugar, beef, corn, wheat and soybeans.



With a correlation, more than 40% of the groups become larger:
1. Fuel (gas, liquefied gas, coal, oil), as well as iron ore, platinum and copper.
2. Logs, chicken, tea, tobacco, beef, cotton, coffee, corn, wheat and soybeans.
3. Gold and silver.
4. Sugar and rice.
5. Aluminum - by itself.



At the threshold of 45% sugar, rice, coffee and coal fall out of the system of links:



The threshold is 50%. One of the groups falls into two:
1. Logs, chicken, tobacco, beef and tea.
2. Corn, soybeans and wheat.



A correlation of more than 55% - a group of gas, liquefied gas, oil, iron, copper and platinum still holds.
The connection between gold and silver falls apart.
Related as: logs with chicken and tobacco, corn with soybeans.



60% threshold:



65%. Only 3 groups remain connected:

1. Gas, liquefied gas and oil.
2. Iron ore and copper.
3. Logs and chicken.



And finally, 70%.
Only gas and liquefied gas prices remain related:

Source: https://habr.com/ru/post/240323/


All Articles