楼主: redaring
8759 21

[程序分享] 请教gamma分布的问题 [推广有奖]

21
redaring 发表于 2010-5-23 13:19:57
我又发现一个问题,如果序列中有负数,则没有办法完成拟合,这个问题怎么解决呢?

22
jingju11 发表于 2010-5-24 11:13:37
21# redaring

The code was based on Hong's.
Not surprisingly, the empirical (observed) percentiles are insensitive to the fitted curves, such as Weibull or Gamma. Clearly, they are nonparametric. However, the estimated percentiles do depend on the distribution you have chosen to fit the model.
For negative values, I just dismiss them. Probably you know those negative values better and can make a transformation.

  1. data a;
  2. infile 'C:\gamma.txt' dsd dlm=',' firstobs=2;
  3. input USAF YEAR MO DA MAX;
  4. run;
  5. proc sort; by USAF MO DA; run;
  6. data b b0;
  7. set a; by USAF MO DA;
  8. if max <=0 then call missing(max); *Gamma has to be positive;
  9. if first.DA then n +1;
  10. output b;
  11. if first.DA then output b0;
  12. run;
  13. ods select FitQuantiles;
  14. ods output FitQuantiles =FitGam(where = (percent in (5, 95)));
  15. proc univariate data=b;
  16. by n;
  17.   histogram max/gamma;
  18. run;
  19. ods output clear;
  20. data c;
  21. merge FitGam b0;
  22. by n;
  23. run;
  24. proc transpose data = c out = final(drop = n _name_) prefix =Max;
  25. id percent;
  26. copy USAF Mo Da;
  27. by n;
  28. var ObsQuantile EstQuantile;
  29. run;
复制代码

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-29 14:00