资源描述:
《《非参数统计》与MATLAB编程第三章符号检验法.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、第三章符号检验法§3.1符号检验函数signtest格式p=signtest(x)原假设为x的中位数为0,显著性水平为0.05的双侧检验。p=signtest(x,m)原假设为x的中位数为m,显著性水平为0.05的双侧检验。p=signtest(x,m,alpha)原假设为x的中位数为m,显著性水平为alpha的双侧检验。[p,h,stats]=signtest(x,m,alpha),当样本小于100时,stats只会显示sign,取x小于假设中位数m的个数与大于假设中位数m的个数的较小值,当样本容量大于或等于100时,stats还将显示'zval'
2、,即正态统计量值。k为大于中位数的个数,当k大于n/2时,±取负号,当k小于n/2时,±号取正号。[p,h]=signtest(...,'alpha',alpha)例:[p,h]=signtest(...,'alpha',0.01)[p,h,stats]=signtest(...,'method',‘exact’)用精确的方法[p,h]=signtest(...,'method',‘approximate’)用正态近似的方法[p,h,stats]=signtest(x,y,'alpha',0.01,'method','exact')[p,h,stat
3、s]=signtest(y1,y2,0.01,'method','approximate')例3.1某市劳动和社会保障部门的资料说明,1998年高级技师的年收入的中位数为21700,该市某个行业有一个由50名高级技师组成的样本,这些高级技师的年收入如下:2307224370203272429622256191402566922404267442674423406204382489024815245561847221514225162511223480265222407418064225902526121180261882162524333231461
4、83243598260402084620438194741921423072267442344324630268932648518138201792674423554257062158817990建立一个50行和1列的向量x,即上面那个数据。a=[];%把上表数据粘到a中b=size(a);x=reshape(a,b(1)*b(2),1);formatlong[p,h,stats]=signtest(x,21700)p=0.06490864707227h=0stats=sign:18sign值的计算:length(x(find(x>21700)))a
5、ns=32length(x(find(x<21700)))ans=18取两者较小值,18。P值的计算:2*(1-binocdf(31,50,0.5))得:0.06490864707229P值也可按:2*(binocdf(18,50,0.5))得:0.06490864707227P值大于缺失的显著性水平0.05,接受原假设。注意:符号检验不能进行单侧检验,那么把双侧检验所得的P值除以2,得新的p值。对于右侧检验:P值的计算:1-binocdf(31,50,0.5)得:0.03245432353615也可用:binocdf(18,50,0.5)得:0.0
6、3245432353614即是双侧检验所得P值的一半。在0.05的显著性水平下拒绝原假设。对于左侧检验P值的计算:length(x(find(x>25000)))ans=13length(x(find(x<25000)))ans=37P值等于:binocdf(13,50,0.5)ans=4.681114554259028e-004也可用:1-binocdf(36,50,0.5)ans=4.681114554372368e-004对于双侧:[p,h,stats]=signtest(x,25000)p=9.362229108518057e-004h=1s
7、tats=sign:13P/2得:4.681114554259028e-004与左侧计算的P值相等。下面我们分析大样本情况:230722437020327242962225619140256692240426744267442340620438248902481524556184722151422516251122348026522240741806422590252612118026188216252433323146183243598260402084620438194741921423072267442344324630268932648518
8、138201792674423554257062158817990230722437020327242962