我正在尝试提取随机森林函数的系数(如线性回归或glm),但是当我调用object $ coef出现“ NULL”时,这是我的代码的一部分:
-Read Data
base <- readxl::read_xlsx("C:/Users/Data.xlsx","PLA")
-Pull columns to use in the model
base_cl <- select(base,
Id = PLA_ID,
Ind = Industry,
Num_Ind =NumInd,
Ret = Ret,
L = Lim,
Expo = Expo,
LPremium = L_P,
HG = HaG,
LPick =LP,
Rate = Rate)
Formula_3 <- Rate ~ Expo + LPremium + Ret + Lim + HG + LPick
output.forest <- randomForest( Formula_3 , base_cl , ntree=1500,
keep.forest=T, importance=T,localImp=T, coef= T)
print(output.forest)
varImpPlot(output.forest, sort = TRUE)
Fit_RF <- predict(output.forest, type="response", newdata = base_cl,
predict.all=T)
base_cl$phat_RF <- Fit_RF$aggregate
我有预测功能,但是我想获取变量的每个系数,以便可以在excel中创建一些具有该结果的函数。 关于我要提取的内容的示例(Expo = .1254,Lim = 5.41,intercept = .22) 谢谢!!