熵权法的计算要点:

  • 区分正向指标与负向指标
  • 权重的计算方法
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
** 熵权法
global xlist1 "X1 X2 X3 X4 X5 X6" // 正向指标
global xlist2 "X7 X8" // 负向指标
global xlist "$xlist1 $xlist2"
*** 正向指标
foreach v of global xlist1 {
egen min_`v'= min(`v')
egen max_`v'= max(`v')
//正向变量标准化
gen `v'_n = (`v'-min_`v')/(max_`v'-min_`v')
egen `v'_sum = sum(`v'_n)
// 第j个指标中第i个样本所占的比重
gen p_`v'= `v'_n/`v'_sum
gen k_`v' = -(1/ln(_N))
egen x_`v' = sum(p_`v'*ln(p_`v'))
//计算第j个指标的熵值
gen e_`v'=k_`v'*x_`v'
//计算差异系数,该系数越大指标越重要
gen g_`v'=1-e_`v'
}
*** 负向指标
foreach v of global xlist2 {
egen min_`v'= min(`v')
egen max_`v'= max(`v')
//负向变量标准化
gen `v'_n = (max_`v'-`v')/(max_`v'-min_`v')
egen `v'_sum = sum(`v'_n)
// 第j个指标中第i个样本所占的比重
gen p_`v'= `v'_n/`v'_sum
gen k_`v' = -(1/ln(_N))
egen x_`v' = sum(p_`v'*ln(p_`v'))
//计算第j个指标的熵值
gen e_`v'=k_`v'*x_`v'
//计算差异系数,该系数越大指标越重要
gen g_`v'=1-e_`v'
}
egen y=rowtotal(g_*),missing
*** 计算第j个指标的权重
foreach v of global xlist {
gen w_`v'= g_`v'/y
gen wn_`v'=w_`v'*`v'_n
}
*** 使用熵权法计算综合指标
egen X=rowtotal(wn_*),missing
foreach v of global xlist {
replace X=. if wn_`v'==.
}
// 删除临时变量
drop min_* max_* *_n *_sum p_* k_* x_* e_* g_* w_* wn_* y

  相关链接:

  【知乎】面板数据熵权法的Stata程序

  【经管之家】stata熵权法命令分享

  ‍