You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to replicate some mgcv functions, and mgcv chooses by default spread out exterior knots. I don't see a way how to replicate this with patsy's BS.
side question: Is there a way to get access to the stateful transform and underlying spline, e.g. BS, instance from the design_info.
(e.g. in general we would need to know which transform patsy applied to the basis function to incorporate the sum to zero or removal of constant constraint, because a transformation of the spline basis and parameters would also have to be applied to the penalization matrix.)
The text was updated successfully, but these errors were encountered:
The trick is that you have to fish out the BS object in a big mess. Then you can change the _all_knots. I didn't really put it in a model I actually used, but I think this does (sort of) what you want.
(I ended up going the opposite route of making sure that np.clip inside the spline so that the unseen data is guaranteed to not have a larger domain).
In line 11, I ran it with the original knots. I changed the knots in 12, and made a new matrix with the new knots in line 13.
AFAICS, patsy sets all exterior knots in
BS
at the same points, i.e. lower_bound and upper_bound.https://github.com/pydata/patsy/blob/master/patsy/splines.py#L229
I'm trying to replicate some mgcv functions, and mgcv chooses by default spread out exterior knots. I don't see a way how to replicate this with patsy's BS.
I started to work again on GAM for statsmodels
statsmodels/statsmodels#5296
side question: Is there a way to get access to the stateful transform and underlying spline, e.g. BS, instance from the
design_info
.(e.g. in general we would need to know which transform patsy applied to the basis function to incorporate the sum to zero or removal of constant constraint, because a transformation of the spline basis and parameters would also have to be applied to the penalization matrix.)
The text was updated successfully, but these errors were encountered: