您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 质量控制/管理 > 《非参数统计》与MATLAB编程第三章符号检验法
第三章符号检验法§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',即正态统计量值。45.02)1(5.0nnkpnpnpkZk为大于中位数的个数,当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,stats]=signtest(y1,y2,0.01,'method','approximate')例3.1某市劳动和社会保障部门的资料说明,1998年高级技师的年收入的中位数为21700,该市某个行业有一个由50名高级技师组成的样本,这些高级技师的年收入如下:23072243702032724296222561914025669224042674426744234062043824890248152455618472215142251625112234802652224074180642259025261211802618821625243332314618324359826040208462043819474192142307226744234432463026893264851813820179267442355425706215881799021700)(:21700)(:10XMHXMHee建立一个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(x21700)))ans=32length(x(find(x21700)))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值。对于右侧检验:21700)(:21700)(:10XMHXMHeeP值的计算:1-binocdf(31,50,0.5)得:0.03245432353615也可用:binocdf(18,50,0.5)得:0.03245432353614即是双侧检验所得P值的一半。在0.05的显著性水平下拒绝原假设。对于左侧检验25000)(:25000)(:10XMHXMHeeP值的计算:length(x(find(x25000)))ans=13length(x(find(x25000)))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=1stats=sign:13P/2得:4.681114554259028e-004与左侧计算的P值相等。下面我们分析大样本情况:230722437020327242962225619140256692240426744267442340620438248902481524556184722151422516251122348026522240741806422590252612118026188216252433323146183243598260402084620438194741921423072267442344324630268932648518138201792674423554257062158817990230722437020327242962225619140256692240426744267442340620438248902481524556184722151422516251122348026522240741806422590252612118026188216252433323146183243598260402084620438194741921423072267442344324630268932648518138201792674423554257062158817990230722437020327242962225619140256692240426744267442340620438248902481524556184722151422516251122348026522240741806422590252612118026188216252433323146183243598260402084620438194741921423072267442344324630268932648518138201792674423554257062158817990根据以上数据建立1列150行的向量bb21700)(:21700)(:10XMHXMHeelength((find(bb21700)))ans=54length((find(bb21700)))ans=96[p,h,stats]=signtest(bb,21700)p=8.150399118268979e-004h=1stats=zval:3.34763598180368sign:54zval值的计算:zval=(96-75-0.5)/(150/4)^0.5(96大于75,减去0.5)zval=3.34763598180368p值的计算:2*(1-normcdf(zval))ans=8.150399118269647e-004对于右侧检验:21700)(:21700)(:10XMHXMHeeP值的计算:上面双侧检验所得P值除以2,即得右侧检验的P值。对于:24000)(:24000)(:10XMHXMHeelength(bb(find(bb24000)))ans=63length(bb(find(bb24000)))ans=87[p,h,stats]=signtest(bb,24000)p=0.06038908130927h=0stats=zval:-1.87794213613377sign:63zval的计算:zval=(63-75+0.5)/(150/4)^0.5(63小于75,加上0.5)zval=-1.87794213613377P值的计算:2*normcdf(zval)ans=0.06038908130927对于左侧检验:24000)(:24000)(:10XMHXMHee把上面双侧检验所得P值除以2,即得左侧检验的P值。值得一提的是:sign(x,y,alpha),是检验x-y是否中位数为0,原假设为x-y的中位数为0,x和y具有相同的长度大小。sign(x,y,alpha)不是检验x和y具有相同的中位数。x变量230722437020327242962225619140256692240426744267442340620438248902481524556184722151422516251122348026522240741806422590252612118026188216252433323146183243598260402084620438194741921423072267442344324630268932648518138201792674423554257062158817990y变量1932433982104020846204381947419214230722674423443246302689326485181382017926744235542570621588179902407223370213272429624256191402566922404267442474423406204382489024815245561947221514225162511223480265222407418064225902526121180281882162529333251460)(:0)(:10YXMHYXMHee[p,h,stats]=signtest(x,y,0.05)p=0.77544965468158h=0stats=sign:23length(z(find(z0)))ans=23length(z(find(z0)))ans=26sign为23和26较小值,为23。x-y有一个值为0。P值的计算:2*binocdf(23,49,0.5)得:0.77544965468158也可按:2*(1-binocdf(25,49,0.5))得:0.77544965468155,大于0.05,接受原假设。习题三1.6200.005100.006300.004900.007100.005700.004900.005200.006600.007200.006500.006900.005500.005800.006400.007000.003900.005100.007500.006300.005400.006000.006700.006000.004800.005800.007200.006200.007100.006900.006000.007300.006600.006300.006800.006200.005500.006300.005400.004800.00注:有一个值等于65006500)(:6500)(:10XMHXMHee[p,h,stats]=signtest(x,6500,'alpha',0.05,'method','exact')p=0.05325191409793h=0stats=sign:13length(find(x6500))ans=13length(find(x6500))ans=26左侧检验的P值为:p/2ans=0.02662595704896在0.05显著性水平,接受备择假设,中位数低于6500。区间估计:中位数me的各层的区间估计第一层:置信度1-0.5^38ans=0.99999999999636或1-binocdf(0,39,0.5)/0.5ans=0.99999999999636第二层:1-0.5^38-39*0.5^38ans=0.99999999985448或:1-binocdf(1,39,0.5)/0.5ans=0.99999999985448第十四层:1-binocdf(13,39,0.5)/0.5ans=0.94674808590207x1=sort(x)x1(14)x1(14)ans=5800x2=wrev(x1
本文标题:《非参数统计》与MATLAB编程第三章符号检验法
链接地址:https://www.777doc.com/doc-2819602 .html