0

we could get

Xp <- predict(mod, newdata = my_new_data, type = 'lpmatrix')

in {mgcv} package.

I am wondering how Xp is being calculated? The definition is X_p is the model matrix where spline covariates s(x) have been replaced by the values of the basis functions b_j(x) evaluated at the respective covariate x.

There are some relevent links How to extract fitted splines from a GAM (`mgcv::gam`) https://stats.stackexchange.com/questions/406566/using-gam-outside-statistical-modelling-software-in-datatabase-outside-r while did not explain how the Xp is extracted.

Grzegorz Sapijaszko
  • 1,913
  • 1
  • 5
  • 12
Vera Liu
  • 1
  • 1

0 Answers0