MATLAB实现LMDI
(2017-07-11 17:08:13)分割线
加性函数========================================================
function out = LMDI_add(C,X,style)
%本函数计算LMDI的总效应Dtot,活动效应Dact,结构效应Dstr和强度效应Dint.
%C表示被研究的对象数据,如碳排,能量等,X表示因素数据,如经济总量,经济结构,消费强度等。
%在计算总效应时,X为空,即为LMDI(C,[],style),[]不可省略。
t=size(C,2);
disp(strcat('输出',style,':'));
if isempty(X) && (~isempty(C)||~isempty(style))
%% 判断并计算总效应
Dtot=sum(C(:,t))-sum(C(:,1));%t时期各部门消费总量与1时期消费总量之差;
out=Dtot;
elseif ~isempty(X) && (~isempty(C)||~isempty(style))
%% 判断并计算活动效应、结构效应和强度效应。
switch style
case
'Dact'
Q=X;
Dact=sum(L(C(:,t),C(:,1)))*log(sum(Q(:,t))/sum(Q(:,1)));
out=Dact;
case
'Dstr'
S=X;
Dstr=sum(L(C(:,t),C(:,1)).*log(S(:,t)./S(:,1)));
out=Dstr;
case
'Dint'
I=X;
Dint=sum(L(C(:,t),C(:,1)).*log(I(:,t)./I(:,1)));
out=Dint;
otherwise
disp('case选项无匹配!')
end
%可用DeltaEtot-(DeltaEact+DeltaEstr+DeltaEint)检验误差大小
else
%% 函数调用有误。
disp('函数参数调用有误')
end
end
%本函数计算LMDI的总效应Dtot,活动效应Dact,结构效应Dstr和强度效应Dint.
%C表示被研究的对象数据,如碳排,能量等,X表示因素数据,如经济总量,经济结构,消费强度等。
%在计算总效应时,X为空,即为LMDI(C,[],style),[]不可省略。
t=size(C,2);
disp(strcat('输出',style,':'));
if isempty(X) && (~isempty(C)||~isempty(style))
%% 判断并计算总效应
Dtot=sum(C(:,t))-sum(C(:,1));%t时期各部门消费总量与1时期消费总量之差;
out=Dtot;
elseif ~isempty(X) && (~isempty(C)||~isempty(style))
%% 判断并计算活动效应、结构效应和强度效应。
switch style
end
%可用DeltaEtot-(DeltaEact+DeltaEstr+DeltaEint)检验误差大小
else
%% 函数调用有误。
end
end
分割线
L函数====================================================
function L=L(x,y)
%% local function L(x,y)
L=(x-y)./(log(x)-log(y));
end
%% local function L(x,y)
L=(x-y)./(log(x)-log(y));
end
分割线 某案例
====================================================
P=transpose([114333
117171
121121
123626
126743
128453
130756
132129
134091
135404
]);
E=transpose([3692.147499
5152.62969
6693.253419
8160.134644
10661.52595
13261.0888
19813.61982
27857.33094
39361.60549
47830.59612
]);
S=transpose([0.1815062170.012589176 0.008599517 0.004024072 0.009887406 0.070008715 0.087148389 0.007725686 0.02828813 0.017184391 0.017280536 0.07777089 0.037348967 0.045282627 0.021382932 0.049475203 0.015764038 0.022784763 0.016115459 0.004021706 0.01405606 0.072086064 0.045106261 0.058841463 0.0757214
0.1326933190.010600061 0.008909881 0.003362326 0.009337567 0.059350099 0.077601046 0.007109372 0.025767688 0.017206056 0.014733076 0.070935298 0.037034739 0.046357126 0.020854127 0.055335376 0.022514414 0.022486771 0.015128994 0.002943806 0.015957319 0.075996579 0.087477483 0.117756729 0.09108436
0.1299371420.008505629 0.009604943 0.004749718 0.011997208 0.068459134 0.087278755 0.010105955 0.027764765 0.018741553 0.016894051 0.077200267 0.039739193 0.051169561 0.022321676 0.04904382 0.025875633 0.025451736 0.024046937 0.002286491 0.005776791 0.085610569 0.033666004 0.085980169 0.077792302
0.1234830870.011146076 0.008163331 0.005978569 0.008880579 0.069016727 0.076892702 0.011214645 0.02211265 0.022172233 0.01550303 0.076120452 0.044071342 0.038905454 0.02493579 0.041165725 0.026589906 0.02782185 0.024500929 0.004154424 0.017820053 0.086995255 0.035153328 0.093820466 0.083381397
0.1026906670.007857622 0.017012342 0.003801054 0.002715739 0.05688469 0.066352262 0.005817947 0.019051083 0.03727104 0.030841644 0.08381656 0.024364443 0.044757375 0.016304301 0.034459499 0.036945154 0.038211039 0.044995408 0.003754957 0.010345828 0.086029149 0.041043229 0.097306776 0.087370191
0.0911804760.012796805 0.010411576 0.004634148 0.005074463 0.046200937 0.049884857 0.012599092 0.022493599 0.028210189 0.019412975 0.068827433 0.018519365 0.049030627 0.019135495 0.041467916 0.03077779 0.022721581 0.041404286 0.005389643 0.00922857 0.08975732 0.048931415 0.156128919 0.095780524
0.0726854350.013425544 0.010539513 0.005957079 0.004190694 0.048298123 0.051666468 0.011022543 0.019995573 0.040507565 0.022879034 0.074322568 0.029321199 0.057911382 0.019421196 0.046129418 0.032543255 0.030346478 0.051925688 0.006930515 0.009142487 0.073593996 0.04626871 0.13145021 0.089525325
0.0597086950.01177865 0.011644114 0.007509652 0.004703634 0.051034912 0.052841735 0.013425915 0.018236361 0.041244104 0.025736501 0.075712785 0.027848964 0.07461111 0.02162213 0.048221481 0.040273653 0.033162017 0.050302012 0.005959102 0.01288305 0.076596506 0.039604951 0.121777536 0.073560431
0.0553321230.016096916 0.009317768 0.009107555 0.004302361 0.05382548 0.045316116 0.012010063 0.016597798 0.038099369 0.024065081 0.074434419 0.031979756 0.06551894 0.01955371 0.052897991 0.046857918 0.036634045 0.045153129 0.005697233 0.01090002 0.081691986 0.039326355 0.132298013 0.072866125
0.0558315650.014053357 0.007657164 0.007793047 0.003961211 0.054918891 0.041384214 0.011706143 0.018326948 0.033414328 0.024982827 0.075563519 0.029098299 0.068750902 0.020121096 0.045833979 0.040369261 0.031221168 0.040459595 0.003416747 0.004794287 0.086544857 0.038689815 0.159776693 0.081330085
]);
I=transpose([0.0003793530.002623701 0.001982877 0.02916343 0.001565364 0.000517993 0.000780485
117171
121121
123626
126743
128453
130756
132129
134091
135404
]);
E=transpose([3692.147499
5152.62969
6693.253419
8160.134644
10661.52595
13261.0888
19813.61982
27857.33094
39361.60549
47830.59612
]);
S=transpose([0.181506217
0.132693319
0.129937142
0.123483087
0.102690667
0.091180476
0.072685435
0.059708695
0.055332123
0.055831565
]);
I=transpose([0.000379353

加载中…