Documentation

dwtest

Durbin-Watson测试

Syntax

p = dwtest(r,x)
p = dwtest(r,x,name,value)
[p,d] = dwtest(___)

Description

example

p= dwtest(r,x)returns thep-value for theDurbin-Watson测试关于线性回归的残差是不相关的无效假设。另一种假设是残差之间存在自相关。

example

p= dwtest(r,x,Name,Value)returns thep- Durbin-Watson测试的价值,并具有由一个或多个名称值对参数指定的其他选项。例如,您可以进行单方面测试或计算p-value using a normal approximation.

example

[p,d] = dwtest(___)also returns the Durbin-Watson test statistic,d, using any of the input arguments from the previous syntaxes.

Examples

collapse all

加载样品普查数据。

loadcensus

Create a design matrix using the census date (cdate) as the predictor. Add a column of1values to include a constant term.

n = length(cdate); x = [ones(n,1),cdate];

Fit a linear regression to the data.

[b,bint,r] = regress(pop,x);

Test the null hypothesis that there is no autocorrelation among the residuals,r.

[p,d] = dwtest(r,x)
p = 0 d = 0.1308

这returned valuep = 0表明在5%的显着性水平上拒绝零假设。

加载样品普查数据。

loadcensus

Create a design matrix using the census date (cdate) as the predictor. Add a column of1values to include a constant term.

n = length(cdate); x = [ones(n,1),cdate];

Fit a linear regression to the data.

[b,bint,r] = regress(pop,x);

Test the null hypothesis that there is no autocorrelation among regression residuals, against the alternative hypothesis that the autocorrelation is greater than zero.

[p,d] = dwtest(r,x,'Tail','对')
p = 0 d = 0.1308

这returned valuep = 0表明在5%的显着性水平上排斥无效假设,有利于替代假设,即残留物之间的自相关大于零。

Input Arguments

collapse all

Design matrix for a linear regression, specified as a matrix. Include a column of1设计矩阵中的值,因此模型包含一个恒定项。

Data Types:single|double

Regression residuals, specified as a vector. Obtainrby performing a linear regression using a function such asregress, or by using the backslash operator.

Data Types:single|double

Name-Value Pair Arguments

Specify optional comma-separated pairs ofName,Value参数。Nameis the argument name and价值是相应的值。Name必须出现在单引号中(' '). You can specify several name and value pair arguments in any order asNAME1,Value1,...,Namen,Valuen.

Example:'Tail','right','Method','approximate'指定右尾假设检验,并使用正常近似计算P值。

collapse all

Computation method for thep- 价值,指定为逗号分隔对'Method'and one of the following.

'精确的' Calculate an exactp-value using the Pan algorithm. This is the default if the sample size is less than 400.
'近似' Calculate thep-value using a normal approximation. This is the default if the sample size is 400 or larger.

Example:“方法”,“精确”

Type of alternative hypothesis to evaluate, specified as the comma-separated pair consisting of'Tail'and one of the following.

'both' Test the alternate hypothesis that autocorrelation among the residuals is not zero.
'对' Test the alternative hypothesis that autocorrelation among the residuals is greater than zero.
'剩下' 测试替代假设,即残留物之间的自相关小于零。

Example:'Tail','right'

Output Arguments

collapse all

p- 测试值,在[0,1]范围内作为标量值返回。pis the probability of observing a test statistic as extreme as, or more extreme than, the observed value under the null hypothesis. Small values ofpcast doubt on the validity of the null hypothesis.

假设检验的测试统计量,作为非负标量值返回。

More About

collapse all

Durbin-Watson Test

Durbin-Watson检验用于检验无效的假设,即线性回归残差是不相关的,与存在自相关的替代方案。

这test statistic for the Durbin-Watson test is

d = t = 2 T ( e t e t 1 ) 2 t = 1 T e t 2 ,

whereTis the number of observations, andet是时间的残留t.

p-value of the Durbin-Watson test is the probability of observing a test statistic as extreme as, or more extreme than, the observed value under the null hypothesis. A significantly smallp- 值对无效假设的有效性产生了怀疑,并表明残留物之间的相关性。这p-value can be calculated exactly using the Pan algorithm. Alternatively, thep-value can be estimated using a normal approximation.

See Also

Introduced in R2006a

这个话题有帮助吗?