0
我正嘗試使用引導包中的函數cv.glm()來驗證線性模型。 首先我運行模式和正常工作:model.frame.default中的錯誤...變量長度不同R中的線性模型驗證
> linear_model_red<-glm(red_wine_data$quality~.,data=red_wine_data)
然後,我想做的驗證:
cv.glm(red_wine_data,linear_model_red)
,並擊掌我的錯誤:
Error in model.frame.default(formula = red_wine_data$quality ~ ., data = list(:
variable lengths differ (found for 'fixed acidity')
我不根本沒有任何缺失的數據,我查了一下。而且我所有的變量都相同lengh:
sapply(red_wine_data,function(x) length(x))
fixed acidity volatile acidity
1599 1599
citric acid residual sugar
1599 1599
chlorides free sulfur dioxide
1599 1599
total sulfur dioxide density
1599 1599
pH sulphates
1599 1599
alcohol quality
1599 1599
volatile acidity*citric acid volatile acidity*sulphates
1599 1599
volatile acidity*alcohol citric acid*sulphates
1599 1599
citric acid*alcohol sulphates*alcohol
1599 1599
please help!