20
Stata Technical Bulletin
STB-57
sg151 В-splines and splines parameterized by their values at reference points on the ..' -axis
Roger Newson, Guy’s, King’s and St Thomas’ School of Medicine, London, UK, [email protected]
Abstract: Two programs are presented for generating a basis of splines in an ^-variable, to be used by regression programs
to fit spline models. The first, bspline, generates a basis of Schoenberg В-splines, which avoid the stability problems
associated with plus-functions. The second, frencurv, generates a basis of reference splines, whose parameters in the
regression model are simply values of the spline at reference points on the ж-axis. These programs are complementary to
existing spline programs in Stata, and do not supersede them.
Keywords: spline, В-spline, interpolation, quadratic, cubic.
Syntax
bspline ∖eewanriitt∖ [if exp [in range∖ , zvar(varname) [ power(#) knots (uumlstt)
noexknot generat e(vɑneɑme) type (type) Iabfmt ( %fnf) ]
frencurv [eewanrisst∖ [if exp [in nɑegp , zva,r(,vɑneɑme') [ power(#) ref pts enrnnlist) noexref
knots(uumlsst) noexknot generate(,rɑnaɑme) type(type) Iabfmt(%fmt) ]
Description
bspline generates a basis of В-splines in an ^-variable, based on a list of knots, for use in fitting a regression model
containing a spline in the ^-variable. frencurv (“French curve”) generates a basis of reference splines, for use in fitting a
regression model, with the property that the fitted parameters will be values of the spline at a list of reference points on the
ж-axis. Usually, the regression command is called with the noconst option.
Options
xvar (vɑneɑme) specifies the ^-variable on which the splines are based.
power (#), a nonnegative integer, specifies the power (or degree) of the splines, for example, zero for constant, 1 for linear, 2
for quadratic, 3 for cubic, 4 for quartic, or 5 for quintic. The default is zero.
knots (eumlist) specifies a list of at least 2 ascending knots, on which the splines are based. If knots are absent, then bspline
will initialize the list to the minimum and maximum of xvar, and f rencurv will create a list of knots equal to the reference
points (in the case of odd-degree splines such as a linear, cubic, or quintic) or midpoints between reference points (in the
case of even-degree splines such as constant, quadratic, or quartic).
noexknot specifies that the original knot list is not to be extended. If noexknot is not specified, then the knot list is extended
on the left and right by power extra knots on each side, spaced by the distance between the first and last 2 original knots,
respectively.
generate (vɑneɑme) specifies a prefix for the names of the generated splines, which (if there is no eewvanlist) will be named
as vaneame1.. .vamameN, where N is the number of splines.
type (type) specifies the storage type of the splines generated (float or double). If type is given as anything else (or not
given), then it is set to float.
Iabfmt %f>m∏t) specifies the format to be used in the variable labels for the generated splines. The default is the format of the
xvar.
ref pts (eumlist) (frencurv only) specifies a list of at least 2 ascending reference points, with the property that, if the splines
are used in a regression model, then the fitted values will be values of the spline at those points. If ref pts is absent, then
the list is initialized to two points, equal to the minimum and maximum of xvar.
noexref (frencurv only) specifies that the original reference list is not to be extended. If noexref is not specified, then the
reference list is extended on the left and right by intppownr/2) extra reference points on each side, spaced by the distance
between the first and last 2 original reference points, respectively.
Remarks
The options described above appear complicated but imply simple defaults for most users. Advanced users and programmers
are given the power to specify a comprehensive choice of nondefault splines. The splines are either given the names in the
eewvanlist (if present), or (more usually) generated as a list of numbered variables, prefixed by the generate option. (The