我有这段代码可以很好地工作:
backMod <- train(Y ~ poly(X, 15),
data = yx,
method = 'glmStepAIC',
direction = 'backward',
trace = 0,
trControl = trainControl(method = 'none',
verboseIter = FALSE))
但是运行此代码时出现错误:
forMod <- train(Y ~ poly(X, 15),
data = yx,
method = 'glmStepAIC',
direction = 'forward',
trace = 0,
trControl = trainControl(method = 'none',
verboseIter = FALSE))
我得到的错误是:
Error in parse(text = x, keep.source = FALSE) :
<text>:1:21: unexpected numeric constant
1: .outcome~poly(X, 15)1
^
我似乎无法弄清楚在给出错误的forMod代码中所做的不同。我了解到此错误表明我的代码中可能在forMod代码第一行附近的地方有一个type-o,但我似乎无法弄清楚到底是什么。任何帮助将不胜感激!