K折使用插入符号包对负二项式回归进行交叉验证?

时间:2018-08-27 04:48:09

标签: r cross-validation r-caret

我正在使用“插入符号”程序包对过度分散的计数数据集在负二项式回归模型(glm.nb)上执行K折交叉验证。我认为由于警告,我使用的方法不正确。

是否有一种方法可以对使用glm.nb函数创建的模型执行交叉验证?评论受到高度赞赏。

代码

data_ctrl <- trainControl(method = "cv", number = 5)
# Run the negtaive binomial regression model
model_caret <- train(Count~Soil.Sal+Temp+Soil.ph, data = CLAB,trControl=data_ctrl, method="lm")
model_caret
model_caret$finalModel

输出

Negative Binomial Generalized Linear Model 

102 samples
  3 predictor

No pre-processing
Resampling: Cross-Validated (5 fold) 
Summary of sample sizes: 81, 82, 82, 82, 81 
Resampling results across tuning parameters:

  link      RMSE      Rsquared   MAE     
  identity       NaN        NaN       NaN
  log       7.680947  0.3695579  5.186753
  sqrt      6.727719  0.3854733  4.751341

RMSE was used to select the optimal model using the smallest value.
The final value used for the model was link = sqrt

Warnings (12)
Warning messages:
1: In log(y/mu) : NaNs produced
2: model fit failed for Fold1: link=identity Error : no valid set of coefficients has been found: please supply starting values

0 个答案:

没有答案