I am studying the effect of organic farming on honey reserves in honeybee colonies. I am trying to see how an increase in the percentage of organically farmed land (at various buffers around bee hives) impacts bee colonies. I would like to create 3-dimensional plots with the percentage difference of honey reserves between colonies that are placed in landscapes with more and less than a certain threshold values of organically farmed land on the z axis, the threshold value on the x-axis and time or buffer radius on the y-axis (with one of the latter two being fixed). Something like this (or something a little more smoothed):

Therefore, I need to model the honey reserves of colonies in colonies that exceed the threshold value and those that don’t. I did this both separately with separate gam models for “> threshold” and “≤ threshold” and with a single gam model:
#1
gam_less <- gam(total.reserves ~ ti(week) , method = "REML",
data=bio.sub_less)
#2
gam_interact <- gam(total.reserves ~ te(week,by = binary) , method = "REML”, data=bio.sub)
I predicted the honey reserves using these models. For model #1 I used this code:
newdat = expand.grid(week,years,unique(bio.sub_less$numero))
names(newdat) = c("week","year","numero")
predicted_less = predict(gam_less,newdat)
predicted_less = predicted_less[1:length(week)]
Analogously I predicted the honey reserves for the colonies exposed to more OF than the threshold. I plotted the observations with a gam smooth:
predict.obs_1000m_10perc.gg = ggplot(predict.obs_1000m_10perc, aes(x=week,y=total.reserves,colour=binary))
predict.obs_1000m_10perc.gg + geom_point(size=0.8) + geom_smooth(method="gam",formula = y ~ ti(x)) +
geom_line(aes(x=week,y=reserves.more.no.random, colour= "gam no random more"))+
geom_line(aes(x=week,y=reserves.less.no.random, colour= "gam no random less"))
I was surprised to see that the gam smooth did not match the gam predictions as you can see here:
(I tried various models, this is the one that got closest to the smooth)
Why is that? Did I make a mistake?
