Possible Duplicate:
Kruskal-Wallis or Fligner test to check homogeneity of variances?
Is there a test to check if the residuls of a linear regression are constant?
Thanks
Possible Duplicate:
Kruskal-Wallis or Fligner test to check homogeneity of variances?
Is there a test to check if the residuls of a linear regression are constant?
Thanks
I'm going to assume you mean a test for constant variance for the residuals. The following R code illustrates the test.
library(lmtest)
# Create data set
y<-sin(1:100)
x<-y+rnorm(100, 0.2, 0.2)
# Build model
lmfit<-lm(y~x)
# Perform the Breusch-Pagan test against heteroskedasticity
res<-bptest(lmfit)
If the p-value returned from the bptest is > 0.2 you cannot reject the null hypothesis of constant variance.