我有一個很大的數據集,我用它來運行帶有一些定性預測變量的線性迴歸模型。我稱之爲數據集WN,定性變量爲OState和DState(美國各州)。在這裏你會看到有WN內OState和DState的62個獨特的價值觀:現在我正在迴歸模型距離來預測房價定性預測變量不出現在迴歸總結輸出中R
> unique(WN$OState)
[1] NY MA PA DE DC VA MD WV NC RI SC NH GA FL AL TN MS ME KY OH IN MI VT IA WI MN SD ND MT CT IL MO KS NE NJ LA AR OK TX CO WY ID UT AZ NM NV CA OR WA
62 Levels: AA AE AK AL AP AR AS AZ CA CO CT DC DE FL FM GA GU HI IA ID IL IN KS KY LA MA MD ME MH MI MN MO MP MS MT NC ND NE NH NJ NM NV NY OH OK OR PA PR PW RI SC SD TN TX UT VA VI VT WA ... WY
> unique(WN$DState)
[1] MA RI NH ME VT CT NY NJ PA DE DC VA MD WV NC SC GA FL AL TN MS KY OH IN MI IA WI MN SD ND MT IL MO KS NE LA AR OK TX CO WY ID UT AZ NM NV CA OR WA
62 Levels: AA AE AK AL AP AR AS AZ CA CO CT DC DE FL FM GA GU HI IA ID IL IN KS KY LA MA MD ME MH MI MN MO MP MS MT NC ND NE NH NJ NM NV NY OH OK OR PA PR PW RI SC SD TN TX UT VA VI VT WA ... WY
,OState和DState如下:
> WN.LR = lm(WN$Rate~WN$Distance+WN$OState+WN$DState)
當我檢查迴歸總結時,我發現只有48個OState和DState預測值被填充,其餘14個丟失。摘要輸出的一小部分在下面給出。例如,你會看到OStateAL缺少輸出:
> summary(WN.LR)
Call:
lm(formula = WN$Rate ~ WN$Distance + WN$OState + WN$DState)
Residuals:
Min 1Q Median 3Q Max
-2370.3 -218.4 -18.9 170.8 9105.7
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.208e+03 6.632e+00 182.171 < 2e-16 ***
WN$Distance 1.626e+00 3.111e-03 522.722 < 2e-16 ***
WN$OStateAR 2.000e+02 7.294e+00 27.419 < 2e-16 ***
WN$OStateAZ 1.981e+02 8.372e+00 23.667 < 2e-16 ***
WN$OStateCA 1.056e+02 7.919e+00 13.340 < 2e-16 ***
WN$OStateCO 1.323e+02 7.332e+00 18.043 < 2e-16 ***
WN$OStateCT -2.019e+02 1.827e+01 -11.048 < 2e-16 ***
WN$OStateDC 5.711e+02 2.178e+01 26.223 < 2e-16 ***
在另一方面,當我檢查與OState =「AL」的實體,我看到有超過6000行:
> WNnew<-subset(WN,OState=="AL")
> nrow(WNnew)
[1] 6213
對此有何解釋?