- class statsmodels.gam.smooth_basis.BSplines(x, df, degree, include_intercept=False, constraints=None, variable_names=None, knot_kwds=None)¶
additive smooth components using B-Splines
This creates and holds the B-Spline basis function for several components.
- xarray_like, 1-D or 2-D
underlying explanatory variable for smooth terms. If 2-dimensional, then observations should be in rows and explanatory variables in columns.
number of basis functions or degrees of freedom; should be equal in length to the number of columns of x; may be an integer if x has one column or is 1-D.
degree(s) of the spline; the same length and type rules apply as to df
If False, then the basis functions are transformed so that they do not include a constant. This avoids perfect collinearity if a constant or several components are included in the model.
Constraints are used to transform the basis functions to satisfy those constraints. constraints = ‘center’ applies a linear transform to remove the constant and center the basis functions.
The names for the underlying explanatory variables, x used in for creating the column and parameter names for the basis functions. If
xis a pandas object, then the names will be taken from it.
option for the knot selection. By default knots are selected in the same way as in patsy, however the number of knots is independent of keeping or removing the constant. Interior knot selection is based on quantiles of the data and is the same in patsy and mgcv. Boundary points are at the limits of the data range. The available options use with get_knots_bsplines are
knots : None or array interior knots
spacing : ‘quantile’ or ‘equal’
lower_bound : None or float location of lower boundary knots, all boundary knots are at the same point
upper_bound : None or float location of upper boundary knots, all boundary knots are at the same point
all_knots : None or array If all knots are provided, then those will be taken as given and all other options will be ignored.
A constant in the spline basis function can be removed in two different ways. The first is by dropping one basis column and normalizing the remaining columns. This is obtained by the default
include_intercept=False, constraints=NoneThe second option is by using the centering transform which is a linear transformation of all basis functions. As a consequence of the transformation, the B-spline basis functions do not have locally bounded support anymore. This is obtained
constraints='center'. In this case
include_interceptwill be automatically set to True to avoid dropping an additional column.
- There are additional attributes about the specification of the splines
- and some attributes mainly for internal use.
create the spline basis for new observations