GAM with many binary factors I am trying to model the blood glucose response at 15-minute intervals after a meal. The meal event has many continuous variables (like time of day, body weight, etc) and many binary variables (like butter, bread, breakfast, etc).
I have tried several approaches. One is to use all of the factors as by-variables, like this:
glucose ~ gam(s(time, by=butter) + s(time, by=bread) + s(time, by=breakfast) + s(weight) + ...)
Another option is to multiply all of the binary variables by time, so that they become smooths of their own:
glucose ~ gam(s(butter*time) + s(bread*time) + s(breakfast*time) + s(weight)
Are either of these on the right track? Is there a better way to handle all these binary factors without losing the time dependency? (E.g. the effect of butter should be smooth between 15 minutes and 30 minutes).
Another option that I am considering is decomposing the glucose signal into ~3 principal components and then training seperate GAMs for these. Then the binary factors could be treated as simple linear predictors.
Thank you for your help!
Edited to include more details as requested.

First of all you are not handling serial correlations in the data.  This will lead to suboptimal fits and lack of a proper basis for confidence intervals, etc.  To remedy that, think of a first-order Markov model or generalized least squares with an AR(1) correlation structure.
Depending on your effective sample size you may have included too many interactions in the model.
In terms of model specification I think it may be more logical to include both absolute time and time since the last meal in the model.  Absolute time can handle circadian and other rhythms, and for that purpose you might use a regression spline with 7-12 knots.  Time since the last meal will be a time-dependent covariate and can be modeled with fewer knots in a regression spline to allow for a smooth decay function.
Interactions is a tough one but you might think about quantifying the amount of carbohydrates in the last meal as an interacting factor (or just as a main effect) instead of looking at particular foods.  Some sort of dimension reduction such as that may be needed.
