I am weighing the efficacy of using one monolithic model, versus splitting out in to two different models (a split model) on about 100,000 rows of data. To do so, I am getting results from my split model like so:
preds <- numeric(nrow(DF))
for (i in 1:nrow(DF))
{
if (DF[i,]$col == condition)
{
preds[i] <- predict(glm1, DF[i,])
}
else
{
preds[i] <- predict(glm2, DF[i,])
}
}
For whatever reason, this seems to be going extremely slow, especially when compared to just getting press for an entire data frame like so:
preds <- predict(glm1,DF)
Do you have any ideas on how I can optimize the first snippet?