Professional Documents
Culture Documents
• setwd("D:/data")
• hprice<-read.csv("hprice1.csv",header=TRUE)
• hq1<-lm(price~bdrms+sqrft+lotsize,data=hprice)
• library(lmtest)
• bptest(hq1)
Kiểm định Phương sai thay đổi
(BP test – tự code)
• hprice$phandusq<-residuals(hq1)*residuals(hq1)
• hq2<-lm(phandusq~bdrms+sqrft+lotsize,data=hprice)
• summary(hq2)
Kiểm định Phương sai thay đổi
(White test)
• Cách 1
bptest(hq1,~I(bdrms^2)+I(sqrft^2)+I(lotsize^2)+bdrms*sqrft+
bdrms*lotsize+sqrft*lotsize,data=hprice)
• Cách 2
bptest(hq1,~I(fitted(hq1))+I(fitted(hq1)^2),data=hprice)
Khắc phục PSTĐ