How to handle gaps in a time series when doing GAMM? I want to apply a GAMM with R to this time series but I am not sure how to handle the station P18, as shown in the figure below.

If I shrink the dataset to the point where P18 ends (i.e. left side of the dashed line) I would loose many reversing trends in P07,P14,P22,P2O  and so on.
The question is thus: can I use the whole dataset including P18? I am not sure what the GAMM is doing with such a gap. what would be if there were more gaps?
any idea is welcome!
 A: If the covariates (not including Julian day) are sufficient to model the response in and of themselves, then the problem of missing data in the one site is irrelevant. For example, if the model were
mod <- gam(porpoise ~ s(temperature) + s(salinity) + s(dist.to.land) +
                      s(site, bs = "re"), data = foo))

Which is an AM with a random effect term for site employed using a random effect s(foo, bs = "re") spline, then we are saying that, irrespective of site, there is a functional, additive relationship between the porpoise acitivity and the 3 covariates. The random effect for site just says that the mean activity per site is allowed to differ, i.e. some sites can have more activity than others in general. You can get the same with gamm() but that does involve a bit more heavy lifting - though if your covariates don't fully model the temporal dependence in the data then you'll need gamm() and a correlation structure for the residuals.
In that case, the lack of data after a certain date in one or more sites is irrelevant because you are not using time itself to model the response, it is the combination of the covariates that is being modelled.
By the way, the generalised in GAM and GAMM relates to the generalisation of the model to non-Gaussian errors. It is the additive bit, the A in the acronyms, that gives the non-linear bit. You are making things difficult for yourself by expressing activity as a % variable because those usually need to be modelled using things like beta regression which are not GLMs and thus are not GAMs. It might be better to work with actual events, counts in other words, and not a %.
