资源描述
统计分析中重要的参数检验
预备知识:
一维实参数的假设有一下三种形式:
(1) 单边检验Ⅰ:H0:θ≤θ0,H1:θ>θ0.
(2) 单边检验Ⅱ:H0:θ≥θ0,H1:θ<θ0.
(3) 双边检验:H0:θ=θ0,H1:θ≠θ0.
一、总体均值的假设检验
1. 单个总体的情况
基本假设:X~Nμ,σ2,X1,X2,⋯,Xn是来自总体X的样本,随机变量服从或近似正态分布,具有方差齐性。
(1) 方差σ2已知时,用统计量Z=X-μ0σ/√n~N(0,1),双边拒绝域Z≥Zα2,单边检验Ⅰ拒绝域Z≥Zα;单边检验Ⅱ拒绝域Z≤-Zα。
(2) 方差σ2未知时,用统计量T=X-μ0S√n~t(n-1),双边拒绝域T≥tα2(n-1),单边检验Ⅰ拒绝域T≥tα(n-1);单边检验Ⅱ拒绝域T≤-tα(n-1)。一般情况下总体方差未知,故较多的时候使用此方法。
2.两个总体的情况
基本假设:X~Nμ1,σ12,X1,X2,⋯,Xn1是来自总体X的样本,Y~Nμ2,σ22,Y1,Y2,⋯,Yn2是来自总体Y的样本,两样本独立。
(1) 方差σ12和σ22已知时,用统计量Z=X-Yσ12n1+σ22n2~N(0,1),双边拒绝域Z≥Zα2,单边检验Ⅰ拒绝域Z≥Zα;单边检验Ⅱ拒绝域Z≤-Zα。
(2) 方差σ12=σ22=σ2未知时,用样本方差替代总体方差,统计量T=X-YSw1n1+1n2~t(n1+n2-2),其中Sw=n1-1)S12+(n2-1)S22n1+n2-2,双边拒绝域T≥tα2(n1+n2-2),单边检验Ⅰ拒绝域T≥tα(n1+n2-2);单边检验Ⅱ拒绝域T≤-tα(n1+n2-2)。
(3) 方差σ12≠σ22且未知时,用Welch法近似t检验,用统计量T=X-YS12n1+S22n2~t(υ)近似成立,其中υ=S12n1+S22n22/((S12)2n12(n1-1)+(S22)2n22(n2-1)),双边拒绝域T≥tα2(υ),单边检验Ⅰ拒绝域T≥tα(υ);单边检验Ⅱ拒绝域T≤-tα(υ)。
3. 成对数据的t检验(paired/matched t-test)
数据是成对出现的,即(Xi,Yi)(i=1,2,⋯,n),则认为用成对t检验要优于两总体均值检验。所谓成对t检验就是令Zi=Xi-Yi(i=1,2,⋯,n),对Z作单个总体均值检验。
R语言命令:
t.test(x, y = NULL, alternative = c("two.sided", "less", "greater"), mu=0, paired = FALSE, var.equal = FALSE, conf.level = 0.95, ...)
x -- a (non-empty) numeric vector of data values.
y -- an optional (non-empty) numeric vector of data values.
alternative -- a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less". You can specify just the initial letter.
mu -- a number indicating the true value of the mean (or difference in means if you are performing a two sample test).
paired -- a logical indicating whether you want a paired t-test.
var.equal --a logical variable indicating whether to treat the two variances as being equal. If TRUE then the pooled variance is used to estimate the variance otherwise the Welch (or Satterthwaite) approximation to the degrees of freedom is used.
conf.level --confidence level of the interval.
formula --a formula of the form lhs ~ rhs where lhs is a numeric variable giving the data values and rhs a factor with two levels giving the corresponding groups.
data --an optional matrix or data frame (or similar: see model.frame) containing the variables in the formula formula. By default the variables are taken from environment(formula).
subset --an optional vector specifying a subset of observations to be used.
na.action --a function which indicates what should happen when the data contain NAs. Defaults to getOption("na.action").
二、 总体方差的假设检验
基本假设:X~Nμ,σ2,X1,X2,⋯,Xn是来自总体X的样本。
1. 单个总体的情况
(1).均值μ已知,统计量χ2=nσ2σ02~χ2(n),其中σ2=1ni=1n(Xi-μ)2,双边检验拒绝域χ2≥χ2α/2(n)或χ2≤χ21-α/2(n),单边检验Ⅰ拒绝域χ2≥χ2α(n),单边检验Ⅱ拒绝域χ2≤χ21-α(n)。
(2).均值μ未知,统计量χ2=(n-1)S2σ02~χ2(n-1),双边检验拒绝域χ2≥χ2α2(n-1)或χ2≤χ21-α2(n-1),单边检验Ⅰ拒绝域χ2≥χ2α(n-1),单边检验Ⅱ拒绝域χ2≤χ21-α(n-1)。一般情况下总体均值未知,故较多时候使用此方法。
2. 两个总体的情况
基本假设:X~Nμ1,σ12,X1,X2,⋯,Xn1是来自总体X的样本,Y~Nμ2,σ22,Y1,Y2,⋯,Yn2是来自总体Y的样本,两样本独立。
(1).均值μ1和μ2已知时,统计量F=σ12σ22~F(n1,n2),其中σ12=1n1i=1n1(Xi-μ1)2,σ22=1n2i=1n2(Yi-μ2)2,双边检验拒绝域F≥Fα/2(n1,n2)或F≤F1-α/2(n1,n2),单边检验Ⅰ拒绝域F≥Fα(n1,n2),单边检验Ⅱ拒绝域F≤F1-α(n1,n2)。
(2). 均值μ1和μ2未知时,统计量F=S12S22~F(n1-1,n2-1),双边检验拒绝域F≥Fα2(n1-1,n2-1)或F≤F1-α2(n1-1,n2-1),单边检验Ⅰ拒绝域F≥Fα(n1-1,n2-1),单边检验Ⅱ拒绝域F≤F1-α(n1-1,n2-1)。
R语言命令:
var.test(x, y, ratio = 1, alternative = c("two.sided", "less", "greater"), conf.level = 0.95, ...)
x, y -- numeric vectors of data values, or fitted linear model objects (inheriting from class "lm").
ratio -- the hypothesized ratio of the population variances of x and y.
alternative -- a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less". You can specify just the initial letter.
conf.level -- confidence level for the returned confidence interval.
formula -- a formula of the form lhs ~ rhs where lhs is a numeric variable giving the data values and rhs a factor with two levels giving the corresponding groups.
data -- an optional matrix or data frame (or similar: see model.frame) containing the variables in the formula formula. By default the variables are taken from environment(formula).
subset -- an optional vector specifying a subset of observations to be used.
na.action -- a function which indicates what should happen when the data contain NAs. Defaults to getOption("na.action").
三、二项分布总体的假设检验
预备知识:二项分布(binomial distribution)是指在只会产生两种可能结果的n次独立重复试验中,当每次试验的a结果概率π保持不变时,求出现a结果次数X=0,1,2,⋯,n的一种概率分布。PX=n!X!n-X!πX(1-π)n-x,X=0,1,2,⋯,n,有X=0nPX=1。若一个随机变量X,它的可能取值是0,1,2,⋯,n,且相应的取值概率满足以上公式,则称次随机变量X服从以n和π为参数的二项分布,记为X~(n,π)。
1.单样本二项检验
近似正态法,当n较大,p和1-p均不太小的时候,比如np(1-p)>5时,统计量u=(p-p0)/p0q0/n,双边检验拒绝域u<uα/2,或者u>u1-α/2。
精确方法,利用公式直接计算P值大小,若大于检验水平则接受原假设,若小于检验水平则拒绝原假设。
R语言命令:
binom.test(x, n, p = 0.5, alternative = c("two.sided", "less", "greater"), conf.level = 0.95)
精确检验
x -- number of successes, or a vector of length 2 giving the numbers of successes and failures, respectively.
n -- number of trials; ignored if x has length 2.
p -- hypothesized probability of success.
alternative -- indicates the alternative hypothesis and must be one of "two.sided", "greater" or "less". You can specify just the initial letter.
conf.level -- confidence level for the returned confidence interval.
2.两样本二项检验
一般情况是两样本率的比较,目的在于对相应的两总体率进行统计推断。假设两样本率分别为P1和P2,当n1与n2均较大,且P1、1-P1、P2、1-P2均不太小,如n2P2、n1P1、n1(1-P1)、n2(1-P2)均大于5时,可利用样本率的分布近似正态分布,以及独立的两个正态变量之差也服从正态分布的性质,采用正态近似法对两总体作统计推断。统计量u=p1-p2Sp1-p2,其中Sp1-p2=X1+X2n1+n2(1-X1+X2n1+n2)(1n1+1n2)。
四、泊松分布总体的假设检验
预备知识:泊松分布(Poisson distribution)作为二项分布的一种极限情况,已发展成为描述小概率事件发生规律的重要分布。随机变量X服从泊松分布,是指在足够多的n次独立试验中,X取值为0,1,2,⋯的相应概率为PX=e-λλXX!,X=0,1,2,⋯。式中参数λ即为总体均数,记做X~P(λ)。
使用条件:1普通性,在充分小的观测单位上X的取值最多为1;2平稳性,X的取值只与观测单位的大小相关,而与观测单位的位置无关;3独立增量性,在某个观测单位上X的取值与其它各观测单位上X的取值无关。
泊松分布的性质:1总体均数λ与总体方差相等;2当n很大,而p很小,且np=λ为常数时,二项分布近似泊松分布;3当λ增大时,泊松分布渐进正态分布。一般而言,λ≥20时,泊松分布资料可作为正态分布做处理;4泊松分布具备可加性。m个互相独立的随机变量服从泊松分布,它们的和也服从泊松分布,且均值为这m个随机变量的均值之和。
1.泊松分布的单样本检验
当总体均数小于20时,可采用直接利用公式计算概率的方式对样本均数与已知均数之间的差别进行有无统计学意义的比较。
近似正态法,当 λ≥20时,可以用正态分布来近似,统计量u=X-λλ,或者统计量X2=(X-λ)2λ~χ21,双边检验拒绝域X2>χ21,1-α。
2.泊松分布的两样本检验
两样本计数分别为X1和X2,可以利用正态近似法进行比较。
当两样本的观察单位数相等,即n1=n2,
X1+X2≥20时,统计量u=X1-X2X1+X2;
5≤X1+X2<20时,统计量u=X1-X2-1X1+X2。
当两样本的观察单位数不相等,即n1≠n2,
X1+X2≥20时,统计量u=X1-X2X1n12+X2n22;
5≤X1+X2<20时,统计量u=X1-X2-1X1n12+X2n22。
其中X1=X1n1和X2=X2n2,检验统计量u近似服从正态分布。
R语言命令:
poisson.test(x, T = 1, r = 1, alternative = c("two.sided", "less", "greater"), conf.level = 0.95)
精确检验
x -- number of events. A vector of length one or two.
T -- time base for event count. A vector of length one or two.
r -- hypothesized rate or rate ratio
alternative -- indicates the alternative hypothesis and must be one of "two.sided", "greater" or "less". You can specify just the initial letter.
conf.level -- confidence level for the returned confidence interval.
展开阅读全文