library(car)
residuals <- seq(0, 4.9, 0.1)
## perform Durbin-Watson test
durbinWatsonTest(residuals)
// A DurbinWatson Test must be performed on a model. The model does not matter.
val drmX = drmParallelize( dense((0 until 50).toArray.map( t => Math.pow(-1.0, t)) ) ).t
val drmY = drmX + err1 + 1
var model = new OrdinaryLeastSquares[Int]().fit(drmX, drmY)
// end arbitrary model
val err1 = drmParallelize( dense((0.0 until 5.0 by 0.1).toArray) ).t
val syntheticResiduals = err1
model = AutocorrelationTests.DurbinWatson(model, syntheticResiduals)
val myAnswer: Double = model.testResults.getOrElse('durbinWatsonTestStatistic, -1.0).asInstanceOf[Double]