楼主: playmore
8243 4

[问答] 请问如何求得一个数在样本分布中的分位数 [推广有奖]

学科带头人

2%

还不是VIP/贵宾

-

TA的文库  其他...

R相关

经济学相关

金融工程

威望
1
论坛币
16309 个
通用积分
7.1397
学术水平
372 点
热心指数
394 点
信用等级
341 点
经验
15297 点
帖子
1194
精华
1
在线时间
1331 小时
注册时间
2007-1-11
最后登录
2023-12-15

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

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
我这里有一张抽样得到的表,
现在我指定了一系列的数,想要得到这些数在原样本中排名的分位数
我感觉类似于求样本分位数的反函数,不知道在SAS里该如何实现,谢谢高手解答

二维码

扫码加我 拉你入群

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

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

关键词:分位数 如何实现 反函数 不知道 如何 样本

playmore邀请您访问ChinaTeX论坛!!!进入ChinaTeX论坛
沙发
jingju11 发表于 2014-2-20 11:09:58 |只看作者 |坛友微信交流群
You may think too much about that. According to empirical distribution function, the sample quantiles should be straightforward. note that the quantiles are not 1 to 1 at all. For example, if you want to get the percentile (in 10th) of weight =102.5 from data set sashelp.class... jingju
  1. data _null_;
  2.         a =102.5;
  3.         set sashelp.class end =Eof;
  4.         n ++(weight <=a);
  5.         if Eof then do;
  6.                 q =round(n/_n_*100,10);
  7.                 put a=q=;
  8.                 end;
  9.         run;
复制代码


a=102.5 q=60
NOTE: There were 19 observations read from the data set SASHELP.CLASS.

使用道具

藤椅
yongyitian 发表于 2014-2-20 12:58:14 |只看作者 |坛友微信交流群
如果抽样表中有多个数, 可以将抽样表与rank后的原表合并.
  1. data big;
  2.    do ID = 1 to 120;
  3.        a = round(ranuni(123)*100, 0.01);
  4.        b = round(ranuni(123)*100, 0.01);
  5.        output;
  6.    end;
  7. run;

  8. proc rank data=big group=100 out=big_q;
  9.    var a b;
  10.    ranks quantile_a quantile_b;
  11. run;
  12.    
  13. data sample;
  14.     do _n_ = 1 to 10;
  15.       p = int(ranuni(12345)*120);
  16.       set big point=p;
  17.       output;
  18.     end;
  19.     stop;
  20. run;
  21. proc sql;
  22. create table sample_q as
  23.     select b.*
  24.     from sample a, big_q b
  25.     where a.id = b.id;
  26. quit;
复制代码
还可以从rank后的原表直接抽样.


使用道具

板凳
playmore 发表于 2014-2-26 10:38:21 |只看作者 |坛友微信交流群
jingju11 发表于 2014-2-20 11:09
You may think too much about that. According to empirical distribution function, the sample quantile ...
多谢回复!

后来我在R里找到了ecdf函数,可以指定一张表生成经验概率密度函数,然后把这个函数赋给一个类似句柄的东西,然后就可以任意指定观测求分位数了

SAS好像没有类似的函数,是不是要自己写了?谢谢!
playmore邀请您访问ChinaTeX论坛!!!进入ChinaTeX论坛

使用道具

报纸
wtmswxl 在职认证  发表于 2014-8-4 20:48:14 |只看作者 |坛友微信交流群
高人,学习了。

使用道具

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

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-25 18:17