R插入包,我如何调整lm中的截距和斜率?

时间:2017-01-19 19:45:31

标签: r r-caret lm

我正在尝试使用R插入包来执行线性回归模型的5倍交叉验证。我是机器学习的新手,但我希望每次“重复”时,新的斜率和截距都适合“训练”数据集。但是,默认情况下,斜率和截距对于所有重复都保持不变,并且测试似乎是在每次重复时推出新的RMSE和Rsquared。有没有办法允许调整拦截?

这是我的代码:

regressControl  <- trainControl(method="repeatedcv",
                            number = 5,
                            repeats = 5)    

regress         <- train(y ~ x,
                   data = myData,
                   method  = "lm",
                   trControl = regressControl)
regress

输出如下:

Linear Regression 

54 samples
 1 predictor

No pre-processing
Resampling: Cross-Validated (5 fold, repeated 5 times) 
Summary of sample sizes: 45, 44, 42, 42, 43, 43, ... 
Resampling results:

  RMSE        Rsquared 
  0.01162334  0.9614908

Tuning parameter 'intercept' was held constant at a value of TRUE

regress$finalModel
Call:
lm(formula = .outcome ~ ., data = dat)

Coefficients:
(Intercept)     x  
   -0.03054      0.01690  

0 个答案:

没有答案