楼主: webgu
9244 13

[问答] SAS可以直接产生指定偏度,峰度的分布数据吗? [推广有奖]

贵宾

学科带头人

95%

还不是VIP/贵宾

-

TA的文库  其他...

Python与统计

SAS与统计

威望
2
论坛币
102549 个
通用积分
3.4687
学术水平
475 点
热心指数
493 点
信用等级
434 点
经验
62369 点
帖子
1555
精华
4
在线时间
2201 小时
注册时间
2009-5-4
最后登录
2025-12-25

初级学术勋章 初级热心勋章 初级信用勋章 中级学术勋章 中级热心勋章 中级信用勋章

楼主
webgu 发表于 2013-8-16 18:50:03 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
如题: SAS可以直接产生指定偏度,峰度的分布数据吗?

如:想办法产生,mean= 2, std=3, kurtosis=4,skewness=5 的这样一个分布的数据吗?

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Kurtosis skewness mean Skew RTO

本帖被以下文库推荐

SAS资源
1. SAS 微信:StatsThinking
2. SAS QQ群:348941365

沙发
zkymath 在职认证  发表于 2013-8-19 11:22:31
还没有软件有这个功能吧? 信息太少了

藤椅
webgu 发表于 2013-8-19 16:54:21
如果偏度,峰度均为0时,是正态分布。那么此时,是可以用rand,rannor等函数实现的。
如查不为0,我就不清楚是否有办法模拟了。
SAS资源
1. SAS 微信:StatsThinking
2. SAS QQ群:348941365

板凳
playmore 发表于 2013-8-20 08:43:37
标准正态分布只有两个参数便可固定,即均值和方差
但是非标准的,用均值、方差,再加上偏度和峰度则不然,同样的偏度和峰度,可以有多个分布
如果我没有记错的话,应该是这样
具体还需要什么参数,我就不清楚了
playmore邀请您访问ChinaTeX论坛!!!进入ChinaTeX论坛

报纸
playmore 发表于 2013-8-20 08:50:40
已有 1 人评分经验 论坛币 学术水平 热心指数 信用等级 收起 理由
webgu + 60 + 60 + 1 + 1 + 1 热心帮助其他会员

总评分: 经验 + 60  论坛币 + 60  学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

playmore邀请您访问ChinaTeX论坛!!!进入ChinaTeX论坛

地板
jingju11 发表于 2013-8-23 05:31:05
Referring to Wicklin's "simulating data with sas"  and the Fleishman's paper  about cubic transformation method in Psychometrika(1978), i am mainly programing  in FCMP, with the help pf Macro facility.
The partial code in FCMP is as below.
In this case, my macro can be called as: Simu_Skew_Kurt(,2 3 4 5,,,100);
let me know if anything wrong.
More Details can be seen in my blog at  http://blog.sina.com.cn/s/blog_a3a926360101f6us.html
  1. proc fcmp;

  2.       %* input coefficients and output targeted moments: variance, skewness, kurtosis;
  3.       subroutine Fleishman(c[*], x[*]) varargs; outargs x;
  4.          x[1] = (c[1]**2) + 6*(c[1]*c[3]) + 2*(c[2]**2) + 15*(c[3]**2); /* variance */
  5.          x[2] = 2*c[2]*((c[1]**2) + 24*(c[1]*c[3]) + 105*(c[3]**2) + 2); /* skewness */
  6.          x[3] = 24*((c[1]*c[3])+(c[2]**2)*(1+(c[1]**2)+28*(c[1]*c[3]))+(c[3]**2)*(12+48*(c[1]*c[3])+141*(c[2]**2)+225*(c[3]**2))); /* excess kurtosis */
  7.       endsub;

  8.    %* input coefficient and output J matrix of Jacobian;
  9.    subroutine FlDeriv(x[*],J[3,3]) varargs; outargs J;
  10.       J[1,1] = 2*x[1] + 6*x[3];
  11.       J[1,2] = 4*x[2];
  12.       J[1,3] = 6*x[1] + 30*x[3];
  13.       J[2,1] = 4*x[2]*(x[1] + 12*x[3]);
  14.       J[2,2] = 2*((x[1]**2) + 24*(x[1]*x[3]) + 105*(x[3]**2) + 2);
  15.       J[2,3] = 4*x[2]*(12*x[1] + 105*x[3]);
  16.       J[3,1] = 24*(x[3] + (x[2]**2)*(2*x[1] + 28*x[3]) + 48*x[3]**3);
  17.       J[3,2] = 48*x[2]*(1 + (x[1]**2) + 28*(x[1]*x[3]) + 141*(x[3]**2));
  18.       J[3,3] = 24*(x[1]+28*x[1]*(x[2]**2)+2*x[3]*(12+48*(x[1]*x[3])+141*(x[2]**2)+225*(x[3]**2))+(x[3]**2)*(48*x[1]+450*x[3]));
  19.    endsub;

  20.    %* Iterations of Newton algorithm to resolve cubic coefficients;
  21.    array cf[1,4]/nosymbols;
  22.    rc =read_array('work.moments4',cf);
  23.    array tr[3];
  24.    %* Assign Targeted moments parameters;
  25.    array ti[3]  (1 . .); ti[2] =cf[1,3]; ti[3] =cf[1,4];
  26.    %* Fleishman coefficients with an initial guess by a polynomial regression;
  27.    array x[3];
  28.    x[1] = 0.95357 -0.05679*ti[3] +0.03520*ti[2]**2 +0.00133*ti[3]**2 ;
  29.    x[2] = 0.10007*ti[2] +0.00844*ti[2]**3                            ;
  30.    x[3] = 0.30978 -0.31655*x[1]                                      ;
  31.    array J[3,3]   ;  %*Jacobian matrix;
  32.    array re[3,3]  ;  %*Intermediate results;   
  33.    array f[3]     ;  %*Objective function;
  34.    array ep[3]    ;  %*Error updates;

  35.    maxIter =&maxIter.; absConv =&absConv.;
  36.    %* Initialize f- objective function;
  37.    call Fleishman(x,tr);
  38.    call subtractMatrix(tr, ti, f);

  39.    mf =absConv +1;
  40.    do iter =1 to maxIter by 1 while(mf >absConv);
  41.       %* Solve error function;
  42.       call FlDeriv(x, J);      
  43.       call inv(J, re);
  44.       call mult(re,f, ep);
  45.       call mult(ep, -1, ep);
  46.       %* Updating coefficients x;
  47.       call addMatrix(x, ep, x);
  48.       %* Updating objection fucntion f;
  49.       call Fleishman(x,tr);
  50.       call SubtractMatrix(tr,ti, f);
  51.       %* Check error in Error allowance;
  52.       mf =0;
  53.       do i =1 to 3;         
  54.          if abs(f[i])>mf then mf =abs(f[i]);
  55.          end;
  56.      end;
  57.    %* Set status variable for if converging;
  58.    call symputx('status', catx(' ', 'Converge in iterations of', iter-1));
  59.    if mf > absConv then do;
  60.       put "!!!!NOT converge in maximum iterations of" maxIter;
  61.       call symputx('status', catx(' ', 'Not Coverge in iterations of', iter-1));
  62.       end;
  63.    %* output solved Fleiman coefficients;
  64.    rc =write_array('work.Fleishman_cubic_coeffs',x);
  65.    run;
复制代码
Jingju
已有 1 人评分经验 论坛币 学术水平 热心指数 信用等级 收起 理由
webgu + 100 + 100 + 5 + 5 + 5 无以言加的佩服!!!!

总评分: 经验 + 100  论坛币 + 100  学术水平 + 5  热心指数 + 5  信用等级 + 5   查看全部评分

7
playmore 发表于 2013-8-23 09:23:39
jingju11 发表于 2013-8-23 05:31
Referring to Wicklin's "simulating data with sas"  and the Fleishman's paper  about cubic transforma ...
京剧大侠,问下你的方法是用方差、偏度和峰度这三个不同阶数的矩列方程
然后用Jacobian求解吗?
那么解就不是唯一的了,就是说分布都不是唯一的
然后在这个随机的分布上再随机得到一组基于该分布的观测值吗?
谢谢!
playmore邀请您访问ChinaTeX论坛!!!进入ChinaTeX论坛

8
webgu 发表于 2013-8-23 09:36:37
jingju11 发表于 2013-8-23 05:31
Referring to Wicklin's "simulating data with sas"  and the Fleishman's paper  about cubic transforma ...
非常感谢京剧大哥。我得好好消化一下。
SAS资源
1. SAS 微信:StatsThinking
2. SAS QQ群:348941365

9
jingju11 发表于 2013-8-23 09:40:21
I am not fully understanding what Fleishman's cubic transformation? I would think it is an approximation. On the other hand, we need 3 coefficients and we have 3 functions. Looks like the solution is unique somehow. JingJu

10
ziyenano 发表于 2013-8-23 17:31:22

个人觉得分布函数是决定唯一分布的,楼上也提到了,指定了均值、方差、峰度、偏度的分布并不唯一。

我的想法是从一个分布出发,适当修改分布函数,实现目的,不过工作只完成了一半,偏度的修改还没有一个很好的方法。

从正态分布出发,其峰度的计算如下:

为了简便,这里只计算N(0,1)N(mu,sig)的计算相似。

QQ截图20130823172411.png

Ps:按照定义计算,正态分布的峰值为3,很多软件都作了减3的处理。


修改密度函数,并计算均值、方差,

QQ截图20130823172423.png

若给定峰度Kurt、均值Mu、方差Sig2,生成随机数

计算出:

k=Kurt/3;

mu=Mu/k;

sig2=Sig2/k;


转化为:

以密度函数 QQ截图20130823172441.png

参数分别为(k,mu,sig2)生成随机数。



偏度的推导:

QQ截图20130823172445.png

还没想到合适的修改方法。


这里只是给出一个想法,有兴趣的朋友可以研究一下,不局限于正态分布,我觉得这是个很有意思的问题。



已有 1 人评分学术水平 热心指数 信用等级 收起 理由
jingju11 + 5 + 5 + 5 好的意见建议

总评分: 学术水平 + 5  热心指数 + 5  信用等级 + 5   查看全部评分

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

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