1
$\begingroup$

In running a large GAM model of the form

mgcv::bam(y ~ te(x, y, k = 100, bs = 'ts'),
          family = binomial,
          discrete = TRUE)

I get this warning

Warning message:
In smooth.construct.tensor.smooth.spec(object, dk$data, dk$knots) :
  reparameterization unstable for margin: not done

and the resultant smooth are wild and clearly not fitted correctly.

This does not occur with "cs" smooths. I have been unable to determine if it occurs with discrete = FALSE as that takes much longer to run. Notably, the distribution of x is highly skewed.

What does this warning mean and how can it be ameliorated?

I note my x data (~200K values) are highly skewed. Positive y values are only ~7%. For "ts" and "tp" smooths with large data, mgcv chooses max.knots points (2000 by default) from which to construct a full thin-plate spline before truncating to k. So I suspect that these points are inadequate for constructing the spline. One can supply these initial points by providing a knots value greater than k, but what would be a good approach to selecting these candidate knots?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.