1、z检验与t检验 z test & t test,宇传华 ,Contents,1. z test z检验 2. One-sample t test单样本t检验 3. Paired-samples t test 配对样本t检验 4. Two independent-samples t test 两独立样本t检验 5. test When variances of the two samples are heterogeneous 方差不齐时两样本均数 检验 6. Two type error in hypothesis test 假设检验中的两类错误,1. z test,z-distributio
2、n versus t-distribution,t,For very large samples, the t-test and z-test are identical,A sampling distribution for H0 showing the region of rejection for a = .05 in a 2-tailed z-test(双侧z检验),A sampling distribution for H0 showing the region of rejection for a = .05 in a 1-tailed z-test (单侧z检验),1. One-
3、sample z test,A sampling distribution for H0 showing the region of rejection for a = .05 in a 2-tailed z-test(双侧z检验),72,2. Two independent-samples z test 两独立样本均数比较的z检验,例5-4 研究正常人与高血压患者胆固醇含量(mg%)的资料如下,试比较两组血清胆固醇含量有无差别。 正常人组 高血压组,1. 建立检验假设, 确定检验水平,即正常人与高血压患者血清胆固醇值总体均数相同;,即正常人与高血压患者血清胆固醇值总体均数不同; = 0.05
4、 2. 计算统计量z 值,3. 确定P 值, 作出推断结论 本例z =10.402.58,故P 0.01,按=0.05水准拒绝H0,接受H1,可以认为正常人与高血压患者的血清胆固醇含量有差别,高血压患者高于正常人。,A sampling distribution for H0 showing the region of rejection for a = .05 in a 2-tailed z-test(双侧z检验),43,在按“完全安装”模式安装后,“工具加载宏”添加分析工具,2. One-sample t test 单样本t检验,This test is used to check hyp
5、otheses about the fact that the mean of random variable X equals to given 0. 适用于样本均数与已知总体均数0的比较。0一般为标准值、理论值或经大量观察得到的较稳定的指标值。 Testing sample X should be a sample of a normal random variable. 检验样本是来自正态总体的随机样本 If X is not normal, t will have an unknown distribution and, strictly speaking, the t-test is
6、 inapplicable. However, according to the central limit theorem, as the sample size increases, the distribution of t tends to be normal. Therefore, if the sample size is big, we can use the t-test even if X is not normal. But there is no way to find out what value is big enough. This value depends on
7、 how X deviates from the normal distribution. Some sources claim that n should be greater than 30, but sometimes even this size is not enough. Alternatively, we can use non-parametric test: Wilcoxon rank-sign test.(见p79,第九章),3. 确定P值,做出推断结论 本例自由度n-135-134,查附表2,得t0.05/2,34=2.032。 因为t t0.05/2,34,故P0.05
8、,表明差异无统计学意义,按 0.05水准不拒绝H0,根据现有样本信息,尚不能认为该地难产儿与一般新生儿平均出生体重不同。,1. 建立检验假设,确定检验水准 H0:0,该地难产儿与一般新生儿平均出生体重相同; H1:0,该地难产儿与一般新生儿平均出生体重不同; 0.05。 2. 计算检验统计量 在=0成立的前提条件下,计算统计量为:,例5.1 以往通过大规模调查已知某地新生儿出生体重为3.30kg.从该地难产儿中随机抽取35名新生儿作为研究样本,平均出生体重为3.42kg,标准差为0.40kg,问该地难产儿出生体重是否与一般新生儿体重不同? 解:0=3.30kg,未知,n=35为小样本,,S=0
9、.40kg,故选用单样本t检验。,=TDIST(1.77,34,2),例5-1 结果图示,=0.05/2,P/2=0.086/2,Example,0 = 0.25 t0.05/2,9 =2.26 t0.05,9 =1.83,=TDIST(2.492,9,2)=0.0343,Excel 计算方法,Excel 计算方法(续),Excel result,SPSS计算方法,SPSS计算方法(续),SPSS result,应用条件,单个样本变量来自随机、独立的正态分布总体,3. Paired-samples t test 配对t检验,也叫Dependent t-test for paired sampl
10、es 非独立样本t检验 This test is used when the samples are dependent; that is, when there is only one sample that has been tested twice (repeated measures) or when there are two samples that have been matched or “paired” 适用于非独立两样本的检验。如每一个个体被前后测量两次;或两组样本1:1配成对子(按每一对子的混杂因素(如年龄、性别)配对)。 The paired t-test assume
11、s that the differences between pairs are normally distributed. If this assumption is violated, it would be better to use: Wilcoxon rank-sign test.(见p79,第九章),同源配对:同一受试对象作两次不同的处理,或一种处理的前后比较异源配对:将受试对象按某些混杂因素(如性别、年龄、窝别等)配成对子,然后将每对中的两个个体随机分配给两种处理(如处理组与对照组)优点:配对设计减少了比较对子间的个体差异。 特点:资料成对,每对数据不可拆分。,配对设计的两种情况
12、,The number of doses of medication needed for asthma attacks before and after relaxation training,例5.2 有12名接种卡介苗的儿童,8周后用两批不同的结核菌素,一批是标准结核菌素,一批是新制结核菌素,分别注射在儿童的前臂,两种结核菌素的皮肤浸润反应平均直径(mm)如表5-1所示,问两种结核菌素的反应性有无差别。,=TDIST(4.519,11,2)=0.0009,Excel计算方法,Excel计算方法与结果,SPSS计算方法,SPSS计算结果,差值的正态性检验(AnalyzeDescriptiv
13、e StatisticsExplore),P值0.05,W法与 D法,我国国标GB4882-85推荐方法,Shapiro-Wilk W法(1965年)适用于Kolmogorov-Smirnov D法(?)适用于,小于3或大于1000怎么办?,H0: 样本对应的总体服从正态分布,表 两种方法对乳酸饮料中的脂肪含量测量结果,H0:d0,应用条件,两变量对子之差来自随机、独立的正态分布总体,Effect size(效应大小),How large is the effect (the difference)? Cohens d Squared correlation coefficient (r2),
14、Effect size: Cohens d,Cohens d: Represents mean difference in standard deviation units,Effect size: Cohens d,Same guidelines for interpreting Cohens d,Percent of variance explained Symbol: r2,Effect size: r2,Effect size: r2,Same guidelines for interpreting r2,4. Two independent-samples t test 两独立样本t
15、 检验,应用于: Experimentaltreatment versus control实验研究完全随机设计(completely random design)Existing groupsmales versus females观察研究Goal :Assess whether the means of the populations that two different samples came from are the same or different (or whether one is greater than the other, in a directional test) 目
16、的:比较两总体均数是否有差异。,应用条件,Random and independent samples Normality Homogeneity of variance 两组变量值分别来自随机、独立的正态分布总体,两独立样本t检验计算公式,称为合并方差(combined/pooled variance),例5.3 25例糖尿病患者随机分成两组,甲组单纯用药物治疗,乙组采用药物治疗合并饮食疗法,二个月后测空腹血糖(mmol/L)如表5-2 所示,问两种疗法治疗后患者血糖值是否不同?,代入公式,得:,H0:1=2,H1:12,0.05,Effect size: Cohens d,Cohens d
17、: Represents mean difference in standard deviation units,Effect size: Cohens d,Same guidelines for interpreting Cohens d,Percent of variance explained Symbol: r2,Effect size: r2,Effect size: r2,Same guidelines for interpreting r2,Excel计算方法,Excel计算方法及结果,SPSS计算方法,SPSS计算结果,方差齐性检验,5. test When variances
18、 of the two samples are heterogeneous 方差不齐时两样本均数比较 检验,两样本方差齐性检验(homogeneity of variance test),两样本方差齐性检验2. LEVENE方差齐性检验(LEVENES TEST OF HOMOGENEITY OF VARIANCE)将原样本观察值作离均差变换,或离均差平方变换然后进行完全随机设计的方差分析,其检验结果用于判断方差是否齐性。因为后者对原数据是否为正态不灵敏,所以比较稳健,且该方法可用于后面章节方差分析的齐性检验。目前均推荐采用LEVENE方差齐性检验,例5.3 的方差齐性检验,=FINV(0.0
19、25,12,11),例5.4 两组小白鼠分别饲以高蛋白和低蛋白饲料,4周后记录小白鼠体重增加量(g)如表5-3所示,问两组动物体重增加量的均数是否相等?,H0:1222,H1:1222,0.05,1n-1= 12-1=11,2 = n-1= 13-1 =12,查附表3F界值表, F0.05/2,(11,12) 3.34 =3.3215F F0.05/2,(11,12) P 0.05差别有统计学意义,即方差不齐同,=FINV(0.05/2,11,12),=2*FDIST(5.402,11,12)=0.007,Excel方差齐性检验,Excel方差齐性检验结果,t 检验实例(表5.4数据),H0:
20、12,H1:12,0.05,=TDIST(7.017,15,2),P=4.16E-06,差异有统计学意义,高蛋白喂养的动物体重高于低蛋白组,Excel做方差不齐的t 检验,Excel做方差不齐的t 检验结果,SPSS计算方法,SPSS计算结果,正态检验结果,The t Test formula,One-sample t test,Two independent samples t test,Paired-sample t test,t test When variances of the two samples are heterogeneous,Statistical Analysis,co
21、ntrol group mean,treatment group mean,Is there a difference?,Slide downloaded from the Internet,What does difference mean?,medium variability,high variability,low variability,The mean difference is the same for all three cases,Slide downloaded from the Internet,6. Two type error in hypothesis test 假设检验中的两类错误,假设检验是针对H0,利用小概率事件的原理对总体参数做出统计推论。无论拒绝H0还是接受H0,都可能犯错误。,