1医学统计学之卡方检验本资料适合于《医学统计学》(中国协和医科大学出版社版本)上机实习参考使用。尤其适合山西医科大学、山西中医学院等医学院校的研究生上机操作SPSS使用。2实习x2检验一、目的要求:●掌握x2检验的基本思想●掌握完全随机设计四格表资料x2检验●掌握配对设计四格表资料x2检验●掌握行×列表资料的x2检验(1)多个样本率比较及两两比较(2)两组或多组构成比的比较●掌握行×列表资料的关联性检验(相关分析)●掌握四格表资料的确切概率法应用3注意事项:1.四格表资料:⑴a、b、c、d四个基本数据是否给出?⑵是否需要校正!完全随机设计四格表资料检验条件①当n≥40且所有T≥5,用普通X2检验②当n≥40,但1T5时,用校正的X2检验③当n40或T≤1时,用四格表确切概率法。④若P≈α,改用四格表确切概率法配对设计四格表资料检验条件①当b+c≥40用普通配对X2检验②当b+c40用校正的X2检验或确切概率法2.行×列表资料:有无1/5的格子的理论数小于5大于1或有格子的理论数T1。3.SPSS不会自动做两两比较4P439第4题完全随机设计卡方检验步骤:1、定义变量5步骤:2、输入数据步骤:3、变量加权步骤:3、变量加权:按频数加权步骤:4、分析:选AnalyzeDescriptiveStatisticscrosstabs…步骤:5、定义:行(row=Group)和列(Column=Effect)用Statistics选择要输出的统计量,常用的有χ2(Chi-square等。普通卡方值连续校正卡方值处理组*效应CrosstabulationCount2122351621261844试验组对照组处理组Total有效无效效应TotalChi-SquareTests20.687b1.00017.9891.00022.8911.000.000.00020.2171.00044PearsonChi-SquareContinuityCorrectionaLikelihoodRatioFisher'sExactTestLinear-by-LinearAssociationNofValidCasesValuedfAsymp.Sig.(2-sided)ExactSig.(2-sided)ExactSig.(1-sided)Computedonlyfora2x2tablea.0cells(.0%)haveexpectedcountlessthan5.Theminimumexpectedcountis8.59.b.确切概率值X2=20.687,p=0.000,按a=0.05水准,拒绝H0,接受H1,差异有统计学意义,可认为试验组有效率高于对照组。13P440第5题配对设计卡方检验步骤:1、定义变量14步骤:2、输入数据15步骤:3、变量加权16步骤:3、变量加权:按频数加权17步骤:4、分析:选AnalyzeDescriptiveStatisticscrosstabs…18步骤:5、定义:行(row=A法)和列(Column=B法)19用Statistics选择要输出的统计量,选择McNemar。20McNemar检验结果P值A法*B法CrosstabulationCount70209055107525100阳阴性A法Total阳性阴性B法TotalChi-SquareTests.004a100McNemarTestNofValidCasesValueExactSig.(2-sided)Binomialdistributionused.a.21p=0.004,按a=0.05水准,拒绝H0,接受H1,差异有统计学意义,可认为A试带阳性检出率高于B试带。22P440第8题行×列表资料的x2检验多个样本率比较步骤:1、定义变量23步骤:2、输入数据24步骤:3、变量加权25步骤:3、变量加权:按频数加权26步骤:4、分析:选AnalyzeDescriptiveStatisticscrosstabs…27步骤:5、定义:行(row=group)和列(Column=effect)28用Statistics选择要输出的统计量,选择Chi-square。29检验结果group*effectCrosstabulationCount954013565309520103010102019090280鳞癌腺癌腺鳞癌小细胞癌groupTotal表达不表达effectTotalChi-SquareTests3.348a3.3413.1593.3682.3581.125280PearsonChi-SquareLikelihoodRatioLinear-by-LinearAssociationNofValidCasesValuedfAsymp.Sig.(2-sided)0cells(.0%)haveexpectedcountlessthan5.Theminimumexpectedcountis6.43.a.30X2=3.348,p=0.341,按a=0.05水准,不拒绝H0,差异无统计学意义,尚不能认为不同类型原发性肝癌的nm23-H1基因的表达率有差别。31补充P100行×列表资料的x2检验多个样本率比较及两两比较步骤:1、定义变量并输入数据32步骤:2、变量加权:按频数加权33步骤:3、分析:选AnalyzeDescriptiveStatisticscrosstabs…34用Statistics选择要输出的统计量,选择Chi-square。35检验结果group*effectCrosstabulationCount301444936453212447162133甲乙丙groupTotal阴转人数阳性数effectTotalChi-SquareTests30.640a2.00032.1242.000.1811.670133PearsonChi-SquareLikelihoodRatioLinear-by-LinearAssociationNofValidCasesValuedfAsymp.Sig.(2-sided)0cells(.0%)haveexpectedcountlessthan5.Theminimumexpectedcountis20.51.a.36X2=30.640,p=0.000,按a=0.05水准,拒绝H0,接受H1,差异有统计学意义,可认为三种疗法对尿路感染治疗效果总的来说有差别。需两两比较Bonferroni检验水准调整法37甲、乙检验结果group*effectCrosstabulationCount30144493645395089甲乙groupTotal阴转人数阳性数effectTotalChi-SquareTests20.979b1.00019.0681.00021.9381.000.000.00020.7431.00089PearsonChi-SquareContinuityCorrectionaLikelihoodRatioFisher'sExactTestLinear-by-LinearAssociationNofValidCasesValuedfAsymp.Sig.(2-sided)ExactSig.(2-sided)ExactSig.(1-sided)Computedonlyfora2x2tablea.0cells(.0%)haveexpectedcountlessthan5.Theminimumexpectedcountis19.28.b.检验水准:a’=0.05/3=0.016738X2=20.979,p=0.000,按a=0.0167水准,拒绝H0,接受H1,差异有统计学意义,可认为甲、乙两种疗法对尿路感染治疗效果有差别,甲疗法优于乙疗法。39甲、丙检验结果group*effectCrosstabulationCount301444321244622688甲丙groupTotal阴转人数阳性数effectTotalChi-SquareTests.218b1.640.0551.815.2191.640.816.408.2161.64288PearsonChi-SquareContinuityCorrectionaLikelihoodRatioFisher'sExactTestLinear-by-LinearAssociationNofValidCasesValuedfAsymp.Sig.(2-sided)ExactSig.(2-sided)ExactSig.(1-sided)Computedonlyfora2x2tablea.0cells(.0%)haveexpectedcountlessthan5.Theminimumexpectedcountis13.00.b.检验水准:a’=0.05/3=0.016740X2=0.218,p=0.640,按a=0.0167水准,不拒绝H0,差异无统计学意义,尚不能认为甲、丙两种疗法对尿路感染治疗效果有差别。41乙、丙检验结果group*effectCrosstabulationCount93645321244414889乙丙groupTotal阴转人数阳性数effectTotalChi-SquareTests24.894b1.00022.8171.00026.2291.000.000.00024.6151.00089PearsonChi-SquareContinuityCorrectionaLikelihoodRatioFisher'sExactTestLinear-by-LinearAssociationNofValidCasesValuedfAsymp.Sig.(2-sided)ExactSig.(2-sided)ExactSig.(1-sided)Computedonlyfora2x2tablea.0cells(.0%)haveexpectedcountlessthan5.Theminimumexpectedcountis20.27.b.检验水准:a’=0.05/3=0.016742X2=24.894,p=0.000,按a=0.0167水准,拒绝H0,接受H1,差异有统计学意义,可认为乙、丙两种疗法对尿路感染治疗效果有差别,丙疗法优于乙疗法。43补充P100行×列表资料的x2检验两组构成比的比较步骤:1、定义变量并输入数据44步骤:2、变量加权:按频数加权45用Statistics选择要输出的统计量,选择Chi-square。步骤:3、分析:选AnalyzeDescriptiveStatisticscrosstabs…46检验结果group*血型CrosstabulationCount476620106239525419621879912039168426患者健康人groupTotalABABO血型TotalChi-SquareTests6.755a3.0806.7763.0795.8361.016426PearsonChi-SquareLikelihoodRatioLinear-by-LinearAssociationNofValidCasesValuedfAsymp.Sig.(2-sided)0cells(.0%)haveexpectedcountlessthan5.Theminimumexpectedcountis17.12.a.47X2=6.755,p=0.080,按a=0.05水准,不拒绝H0,差异无统计学意义,尚不能认为胃十二指肠患者与健康输血员血型分布有差别48补充P101行×列表资料的x2检验关联性检验(相关分析)步骤:1、定义变量并输入数据49步骤:2、变量加权:按频数加权50用Statistics选择要输出的统计量,选择Chi-square和ContingencyCoefficient。步骤:3、分析:选AnalyzeDescriptiveStatisticscrosstabs…51检验结果group*季节CrosstabulationCou