我正在尝试运行一个Boosted回归树,因为我想预测(G)的未来场景,但在我构建模型后,我尝试实际预测我的因变量(G),我得到一个错误。
loyn<-read.csv("FullData.csv", strip.white=T, header=T, sep=',')
library(gbm)
head(loyn)
#G Site P O T Coral.Cover OCC PPC
#1 23.023128 Lizard 27.494517 3.702791 25.470 4.2 8.2 20.9
#2 11.547282 Lizard 20.413183 3.664939 25.430 4.2 8.2 20.9
loyn.gbm<-gbm(G~Site+P+O+T+loyn$Coral.Cover+OCC+PPC, data=loyn, distribution="gaussian", train=0.75, interaction.depth=3, shrinkage=0.001, bag.fraction=0.5,cv.folds=3, n.minobsinnode=2, n.trees=10000)
par(mfrow=c(1,2))
(best.iter<-gbm.perf(loyn.gbm, method="cv", overlay=T, oobag.curve=T))
summary(loyn.gbm, n.trees=best.iter)
# here I am asking what value G would have if Site=5, P=20, O=2.7, T=32, #loyn$Coral.Cover=4, OCC=2, PPC=20
new<-predict(loyn.gbm, newdata=data.frame(Site=5, P=20, O=2.7, T=32, loyn$Coral.Cover=4, OCC=2, PPC=20),n.trees=best.iter)
但它一直在说
错误:意外&#39; =&#39; in&#34; new&lt; -predict(loyn.gbm,newdata = data.frame(Site = 5,P = 20,O = 2.7,T = 32,loyn $ Coral.Cover =&#34;
我已经检查过,这不是拼写错误。任何帮助将非常感激。谢谢!