...
 
Commits (2)
......@@ -92,10 +92,11 @@ if(as.character(best_models$estimation_method[m])=="Random Forest"){
, data=subset(modeldata, ind==1 & modeling_group==as.character(best_models$modeling_group[m]))))
}
if(as.character(best_models$estimation_method[m])=="GBM"){
model <- try(gbm(aas.formula(as.character(best_models$form[m]))
model <- try(gbm(as.formula(as.character(best_models$form[m]))
,distribution="gaussian"
,interaction.depth=2
,n.trees=ntree
,cv.folds = 1
,data=subset(modeldata, ind==1 & modeling_group==as.character(best_models$modeling_group[m]))))
}
if (!exists("model")){
......@@ -103,7 +104,11 @@ if (!exists("model")){
next
}
print(summary(model))
if(class(model)=="rq"){
print(summary(model, se = "iid"))
}else{
print(summary(model))
}
# 1. Value estimation ----
if(as.character(best_models$estimation_method[m])=="Random Forest"
......@@ -135,12 +140,37 @@ if(as.character(best_models$estimation_method[m])=="OLS"
TF <- assmntdata$modeling_group==as.character(best_models$modeling_group[m])
assmntdata$fitted_value_1[TF] <- predict(model, newdata=assmntdata[TF,])
}
if(as.character(best_models$estimation_method[m])=="Quantile"
& as.character(best_models$type[m])=="lin-lin"){
TF <- assmntdata$modeling_group==as.character(best_models$modeling_group[m])
assmntdata$fitted_value_1[TF] <- predict.rq(model, newdata=assmntdata[TF,],na.action = na.pass)
& as.character(best_models$type[m])=="log-log"){
TF <- assmntdata$modeling_group==as.character(best_models$modeling_group[m])
assmntdata$fitted_value_1[TF] <- exp(predict(model, newdata=assmntdata[TF,]))
}
if(as.character(best_models$estimation_method[m])=="Quantile"
& as.character(best_models$type[m])=="lin-lin"){
print(paste0("Estimating ", best_models$modeling_group[m]))
TF <- assmntdata$modeling_group==as.character(best_models$modeling_group[m])
assmntdata$fitted_value_1[TF] <- predict(model, newdata=assmntdata[TF,])
}
if(as.character(best_models$estimation_method[m])=="GBM"
& as.character(best_models$type[m])=="log-log"){
TF <- assmntdata$modeling_group==as.character(best_models$modeling_group[m])
assmntdata$fitted_value_1[TF] <- exp(predict(model, newdata=assmntdata[TF,], n.trees=ntree))
}
if(as.character(best_models$estimation_method[m])=="GBM"
& as.character(best_models$type[m])=="lin-lin"){
print(paste0("Estimating ", best_models$modeling_group[m]))
TF <- assmntdata$modeling_group==as.character(best_models$modeling_group[m])
assmntdata$fitted_value_1[TF] <- predict(model, newdata=assmntdata[TF,], n.trees=ntree)
}
print(paste0("Check ", nrow(subset(assmntdata, is.na(fitted_value_1) & modeling_group==as.character(best_models$modeling_group[m]))),
" Out of ", nrow(subset(assmntdata, modeling_group==as.character(best_models$modeling_group[m]))),
......