[R] mgcv::gam is it possible to have a 'simple' product of 1-d smooths?

Mathew Guilfoyle mrguilfoyle at gmail.com
Wed Jan 17 11:28:12 CET 2018

I am trying to test out several mgcv::gam models in a scalar-on-function regression analysis.

The following is the 'hierarchy' of models I would like to test:

(1)  Y_i = a + integral[ X_i(t)*Beta(t) dt ]

(2)  Y_i = a + integral[ F{X_i(t)}*Beta(t) dt ]

(3)  Y_i = a + integral[ F{X_i(t),t} dt ]

equivalents for discrete data might be:

1)  Y_i = a + sum_t[ L_t * X_it * Beta_t ]

(2)  Y_i = a + sum_t[ L_t * F{X_it} * Beta_t ]

(3)  Y_i = a + sum_t[ L_t * F{X_it,t} ]

where Y_i are scalar outcomes for the i-th subject, and X_i(t) is a functional covariate observed at times t in [0,1,...T], and L are the quadrature weights.  Beta() and/or F{} are the functions to be estimated.   Intuitively, model 1 is a linear functional model with a (potentially non-linear) time-dependent regression coefficient (beta()) for the covariate.  Model 2 allows for a non-linear function of the covariate (F{}), but which is constant over time.  Model 3 is the full 'functional GAM' that allows for a fully flexible non-linear covariate- and time- dependent function.  

In my mind at least these would seem to form a natural step-by-step approach of increasing complexity for exploring this type of regression model.

Models 1 (linear functional) and 3 (functional GAM) are relatively straightforward to do with matrix arguments to mgcv::gam.  Assume N subjects observed at T time points.  Y is the length-N vector of scalar outcomes and X, T, and W are the N*T matrices of the functional predictor data values, their observation times, and trapezoidal quadrature weights, respectively.

Models (1) and (3) could be obtained with:

   m1 = gam(Y ~ s(T, by=I(X*W), bs='ps')
   m3 = gam(Y ~ te(X, T, by=W), bs='ps')

However, I cannot find a way to achieve model (2) where there is a 'simple' product of the smooth functions of X and T.  Effectively what I need (I think) is a way of creating a `te()` tensor product smooth but somehow constraining each marginal smooth to be the same for all values of the other variable?  Is this possible?

More information about the R-help mailing list