楼主: 13357739332
12565 26

[数据管理求助] 求助!!!怎么用赫芬达尔hhi指数衡量异质性,stata怎么实现 [推广有奖]

11
13357739332 发表于 2018-11-20 12:17:56
黃河泉 发表于 2018-11-20 07:27
若是如楼上所言,请 search entropyetc, 安装并见其 help 档。
[CODE]
* Example generated by -dataex-. To install: ssc install dataex
clear
input str6 stkcd str10 reptdt byte(age degree)
"000002" "2017-12-31" 53 4
"000002" "2017-12-31" 43 4
"000002" "2017-12-31" 52 4
"000002" "2017-12-31" 49 5
"000002" "2017-12-31" 55 4
"000002" "2017-12-31" 40 4
"000002" "2016-12-31" 52 4
"000002" "2016-12-31" 44 3
"000002" "2016-12-31" 55 4
"000002" "2016-12-31" 39 4
"000002" "2016-12-31" 42 4
"000002" "2016-12-31" 51 4
"000002" "2016-12-31" 54 4
end
您好,我下载了entropyetc命令,不过我没看懂它怎么用的,您能示范一下上面最后两个代码age和degree的Blau指数命令嘛

12
黃河泉 在职认证  发表于 2018-11-20 12:33:47
[quote]13357739332 发表于 2018-11-20 12:17
  1. * Example generated by -dataex-. To install: ssc install dataex
  2. clear
  3. [/quote]
  4. 类似[code]entropyetc age, by(stkcd)
复制代码

13
13357739332 发表于 2018-11-20 12:40:52
黃河泉 发表于 2018-11-20 12:33
类似
我试了entropyetc degree,by(stkcd reptdt),结果是no observations
怀疑是因为stkcd和reptdt是字符的原因
然后我把stkcd reptdt,decode了一下,重新输入,结果是too few quotes,现在也不知道哪出问题了

14
黃河泉 在职认证  发表于 2018-11-20 15:40:33
13357739332 发表于 2018-11-20 12:40
我试了entropyetc degree,by(stkcd reptdt),结果是no observations
怀疑是因为stkcd和reptdt是字符的原 ...
请给一个"代表性"之资料。

15
黃河泉 在职认证  发表于 2018-11-20 15:44:27
13357739332 发表于 2018-11-20 12:40
我试了entropyetc degree,by(stkcd reptdt),结果是no observations
怀疑是因为stkcd和reptdt是字符的原 ...
的确,但请试试
  1. * Example generated by -dataex-. To install: ssc install dataex
  2. clear
  3. input str6 stkcd str10 reptdt byte(age degree)
  4. "000002" "2017-12-31" 53 4
  5. "000002" "2017-12-31" 43 4
  6. "000002" "2017-12-31" 52 4
  7. "000002" "2017-12-31" 49 5
  8. "000002" "2017-12-31" 55 4
  9. "000002" "2017-12-31" 40 4
  10. "000002" "2016-12-31" 52 4
  11. "000002" "2016-12-31" 44 3
  12. "000002" "2016-12-31" 55 4
  13. "000002" "2016-12-31" 39 4
  14. "000002" "2016-12-31" 42 4
  15. "000002" "2016-12-31" 51 4
  16. "000002" "2016-12-31" 54 4
  17. end

  18. destring stkcd, gen(id)
  19. gen ymd = date(reptdt, "YMD")
  20. gen year = year(ymd)

  21. // OK
  22. entropyetc age, by(id year)

  23. // 不 OK
  24. entropyetc age, by(stkcd reptdt)
复制代码

16
13357739332 发表于 2018-11-20 17:51:40
黃河泉 发表于 2018-11-20 15:44
的确,但请试试
黄老师,现在是这样的、
就用一部分样本输出结果是下面,不知道怎么得到我的Blau值
------------------------------------------------------------------------
      Group |  Shannon H      exp(H)     Simpson   1/Simpson     dissim.
------------+-----------------------------------------------------------
000002 2015 |      1.609       5.000       0.200       5.000       0.583
000002 2016 |      1.946       7.000       0.143       7.000       0.417
000002 2017 |      1.792       6.000       0.167       6.000       0.500
------------------------------------------------------------------------
还有就是,我全样本做命令,显示matsize too small,是不是set matsize xxx就好了,具体我也不知道是什么意思

17
13357739332 发表于 2018-11-20 17:59:03
黃河泉 发表于 2018-11-20 15:44
的确,但请试试
刚试了一下,set matsize 10000还是不行
matsize too small
    You have attempted to create a matrix with too many rows or columns or
    attempted to fit a model with too many variables.  You need to increase
    matsize; it is currently 10000.  Use set matsize; see help matsize.

    If you are using factor variables and included an interaction that has lots of
    missing cells, either increase matsize or set emptycells drop to reduce the
    required matrix size; see help set emptycells.

    If you are using factor variables, you might have accidentally treated a
    continuous variable as a categorical, resulting in lots of categories.  Use the
    c. operator on such variables.

18
黃河泉 在职认证  发表于 2018-11-20 18:01:41
13357739332 发表于 2018-11-20 17:51
黄老师,现在是这样的、
就用一部分样本输出结果是下面,不知道怎么得到我的Blau值
------------ ...
请看看 https://en.wikipedia.org/wiki/Diversity_index,当中有说明
  1. The Gibbs–Martin index of sociology, psychology and management studies,[11] which is also known as the Blau index, is the same measure as the Gini–Simpson index.
复制代码

19
黃河泉 在职认证  发表于 2018-11-20 18:13:39
13357739332 发表于 2018-11-20 17:59
刚试了一下,set matsize 10000还是不行
matsize too small
    You have attempted to create a  ...
这种问题我无法回答!

20
13357739332 发表于 2018-11-20 18:25:17
黃河泉 发表于 2018-11-20 18:01
请看看 https://en.wikipedia.org/wiki/Diversity_index,当中有说明
我算了一下,是对的。真的谢谢您呀,给您一个大大的赞!剩下的我自己再去琢磨一下,万谢!!!!
[em17][em17][em17]

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-26 11:37