TITLE(ns @@ Generate a Basis Matrix for Natural Cubic Splines )
USAGE(
ns(x, df, knots, intercept=F, Boundary.knots)
)
ARGUMENTS(
ARG(x@@)
the predictor variable.
ARG(df@@)
degrees of freedom. One can supply LANG(df) rather than knots; LANG(ns()) then
chooses LANG(df-1-intercept) knots at suitably chosen quantiles of LANG(x).
ARG(knots@@)
breakpoints that define the spline. The default is no knots; together with the natural boundary conditions this results in a
basis for linear regression on LANG(x). 
Typical values are the mean or median for one knot, quantiles for 
more knots. See also LANG(Boundary.knots).
ARG(intercept@@)
if LANG(TRUE), an intercept is included in the basis; default is LANG(FALSE).
ARG(Boundary.knots@@)
boundary points at which to impose the natural boundary conditions and 
anchor the B-spline basis (default the range of the data). 
If both LANG(knots) and LANG(Boundary.knots) are supplied, the basis parameters
do not depend on LANG(x). Data can extend beyond LANG(Boundary.knots)
)
PARA BOLD(VALUE)
a matrix of dimension LANG(length(x) * df) where either LANG(df) was supplied or
if LANG(knots) were supplied, LANG(df = length(knots) + 1 + intercept).
Attributes are returned that correspond to the arguments to LANG(ns), and
explicitly give the LANG(knots), LANG(Boundary.knots) etc for use by LANG(predict.ns()).

LANG(ns()) is based on the function LANG(spline.des()) written
by Douglas Bates.  It generates a basis matrix for representing the family of piecewise-cubic splines with the specified sequence of interior knots, and the natural boundary conditions. 
These enforce the constraint that the function is linear beyond the boundary knots, which can either be supplied, else default to the extremes of the data.
A primary use is in modeling formula to directly specify a natural spline term in a model. 

Beware of making predictions with new LANG(x) values when LANG(df) is used as an argument. Either use LANG(safe.predict.gam()), or else specify LANG(knots) and LANG(Boundary.knots).SA
LANG(bs), LANG(poly), LANG(lo), LANG(s), LANG(predict.ns)
BLANK

PARA BOLD( )
BLANK

EXAMPLES(
lsfit(ns(x,5),y)
lm(y ~ ns(age, 4) + ns(income, 4)) # an additive model 
fit <- lm(y ~ ns(age, knots=c(20,30), B=c(10,60)))
predict(fit, new.age) #safe predictions because explicit knot sequence was supplied.
)
PARA ITALIC(File automatically converted from S(-PLUS) help format)
