durbinWatson S-PLUS Language Reference The Durbin-Watson Statistic DESCRIPTION: Computes the Durbin-Watson statistic for testing first-order autocorrelation in regression residuals. The input is either the residual vector or bdNumeric, or an object that inherits from class "lm" or class bdLm. If one of the latter two, the residuals are extracted from the object using the residuals function. USAGE: durbinWatson(x) REQUIRED ARGUMENTS: x either a numeric vector or bdNumeric or an object that inherits from class "lm" or "bdLm". VALUE: a list of class "durbinWatson" with the following components: statistic the value of the Durbin-Watson statistic for x. nobs the number of observations that were used to compute the statistic. This is the number of observations in the data set, minus the number of missing and infinite values. DETAILS: The default method for this function operates on a numeric vector. The method for class "lm" extracts the residuals from the object x using the residuals function, and then calls the default method on those residuals. Currently, the only method for objects of class "durbinWatson" is print. BACKGROUND: The Durbin-Watson statistic tests for first-order autocorrelation in least squares regression residuals. It is defined as sum((diff(x))^2)/var(x, SumSquares=T). The statistic is bounded between 0 and 4; small values indicate possible positive autocorrelation and large values indicate possible negative autocorrelation. For completely independent residuals, the statistic is symmetric around 2. If the test is significant, the observations in your data set may not be independent and you should check the validity of your model assumptions. NOTE: The null distribution for the Durbin-Watson test statistic depends on the data matrix used to compute the linear model. Thus, significance tables are not built into S-PLUS. Instead, you can obtain approximate bounds for significance levels using the tables found in Durbin and Watson (1950); these tables are also available in many general statistics texts. REFERENCES: Durbin, J. and Watson, G.S. (1950). Testing for serial correlation in least squares regression I. Biometrika 37: 409-428. SEE ALSO: lm , residuals . EXAMPLES: cornreg <- lm(corn.yield ~ corn.rain) durbinWatson(cornreg)