全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
12198 11
2012-07-09
用Proc UNIVARIATE 做好了一列数据的拟合分布。
拟合的方法在帖子:
https://bbs.pinggu.org/thread-1479465-1-1.html
如何用SAS求出在该拟合分布下的函数的分位数??

例如:使用正态分布 拟合了数据,得到了分布的参数:均值:0.4,标准差:0.2
然后如何用sas求出在该分布下的P25  P50  P75 等分位数?
即F(x1) = 0.25 , F(x2) = 0.5, F(x3) = 0.75 ...

目的是比较数据的真实分位数值与拟合分布得出的分位数值 的差距。

谢谢!


二维码

扫码加我 拉你入群

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

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

全部回复
2012-7-9 13:04:14
univariate output
univariate  output中有分位数观测值与估计值的比较~

如果觉得不够详细;可以调用估计的参数值,SAS可以计算分位数,以正态分布为例:
data a;
do i=1 to 100;
a=rannorm(0)*10+5;
output;
end;
run;
ods select parameterestimates;
proc univariate data=a ;
histogram a/normal;
ods output parameterestimates=para;

data _null_;
set para;
if _n_=1 then call symput('mu',estimate);
if _n_=2 then call symput('sig',estimate);

data Quartile;/*估计分位数*/
do q=0.025 to 0.975 by 0.025;
Quartile=probit(q)*&sig+μ
output;

end;
run;
二维码

扫码加我 拉你入群

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

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

2012-7-9 13:27:35
ziyenano 发表于 2012-7-9 13:04
univariate  output中有分位数观测值与估计值的比较~

如果觉得不够详细;可以调用估计的参数值,SAS可 ...
谢谢! 我在Output里面看到了, 后来用
proc univariate;
histogram a/normal (percents = 5 10 15 20 25 30 35 40....);
这样可以在output里面输出estimate的分位值 和真实的分位值。

用你计算的方法也非常好,谢谢!
另外问两个问题:
1)如何将OUTPUT上的统计结果及分位值输出到sas中,或者输出到excel里? 用output 感觉很难实现阿?
2)如何计算 下面假设检验的P值?
原假设:数据x服从 该分布
备选假设:数据x不服从该分布

谢谢啦


二维码

扫码加我 拉你入群

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

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

2012-7-9 13:52:39
sailingyf 发表于 2012-7-9 13:27
谢谢! 我在Output里面看到了, 后来用
proc univariate;
histogram a/normal (percents = 5 10 15 20 25 ...
(1)SAS output 其实是分模块的,你在proc步之前加上ods trace on;就能看见每个模块的label,name,path 等;
通常只要 ods output name=输出数据集名; 不过这只是最基本的用法,SAS ods系统很强大,你可以看看帮助文档。
(2)P值计算,不得不扯统计量,数据分布假设检验通常为 皮尔逊卡方检验,柯尔莫哥洛夫检验。前者使用卡方统计量,后者使用D统计量,在分布基础上计算P值;
P值计算很烦,一下我也说不清,一般数理统计里都有介绍,百度一下。P值通俗讲,就是度量根据统计量计算结果,拒绝或者接受原假设的程度。
另外,谢谢你的提醒histogram a/normal (percents = 5 10 15 20 25 30 35 40....),我还不清楚proc univariate有这个功能。
二维码

扫码加我 拉你入群

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

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

2012-7-9 14:01:52
看一下我这张图.  图像看起来非常符合正态分布。
normal.jpg
SAS output结果如下:


                               Parameter   Symbol   Estimate

                                   Mean        Mu       0.467856
                                   Std Dev     Sigma    0.193649


                           Goodness-of-Fit Tests for Normal Distribution

                     Test                  ---Statistic----   -----p Value-----

                     Kolmogorov-Smirnov    D     0.01143319   Pr > D     <0.010
                     Cramer-von Mises      W-Sq  0.30026701   Pr > W-Sq  <0.005
                     Anderson-Darling      A-Sq  3.10816502   Pr > A-Sq  <0.005


                                  Quantiles for Normal Distribution

                                             ------Quantile------
                                   Percent   Observed   Estimated

                                       1.0    0.04494     0.01736
                                       5.0    0.14636     0.14933
                                      10.0    0.21098     0.21968
                                      25.0    0.33080     0.33724
                                      50.0    0.46982     0.46786
                                      75.0    0.59886     0.59847
                                      90.0    0.72291     0.71603
                                      95.0    0.79499     0.78638
                                      99.0    0.89970     0.91835

KS对应的P-value这么小. P<0.01.

可是如果按照SAS Help里面写的
The Kolmogorov-Smirnov D statistic, the Anderson-Darling statistic, and the Cramér-von Mises statistic are based on the empirical distribution function (EDF). However, some EDF tests are not supported when certain combinations of the parameters of a specified distribution are estimated. See Table 3.62 for a list of the EDF tests available. You determine whether to reject the null hypothesis by examining the p-value that is associated with a goodness-of-fit statistic. When the p-value is less than the predetermined critical value (), you reject the null hypothesis and conclude that the data did not come from the specified distribution.

如果设定 0.05的置信标准,那就应该认为该分布不符合正态分布了。
是不是我的理解有问题,为什么p值这么小?


附件列表
normal.bmp

原图尺寸 1.96 MB

normal.bmp

二维码

扫码加我 拉你入群

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

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

2012-7-9 14:14:07
ziyenano 发表于 2012-7-9 13:52
(1)SAS output 其实是分模块的,你在proc步之前加上ods trace on;就能看见每个模块的label,name,path ...
嗯,谢谢讲解!
1、ODS的方法我试试。 以前只是输出一些报表时,用ods。 proc tabulate等。。

2、P值我基本明白了,看来每个统计量后,都会计算一个p值,但是sas help或着百度上都说p值越大越好(应大于置信区间),可是是不是真的越大越好?请参考我上面给出的例子。

再次非常感谢!
二维码

扫码加我 拉你入群

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

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

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群