Please do read the help page: 4 is the number of degrees of freedom.
Each knot introduces just one parameter. Although the help page does not
actually say so AFAICS, these are B-splines, and coefficients of the
B-spline basis -- see any good book on splines.
I think if you want to use splines, you do need a basic familiarity with
the underlying theory (as well as the help pages of the functions you are
using).
On Sat, 27 Mar 2004, Abhilash Sreekumar Nair wrote:
> Dear All,
>
> I am using S-plus 6.0 for windows, I want to fit a natural cubic spline on
> a dataset. I have used the following command:
>
> fit.nif4<-lm(y ~ns(x,4)), (where 4 stands for the number of knots, please
> do correct me if I am wrong.)
>
> My problem is that as I go on increasing the knots the no. of coefficients
> go on increasing, (sample results are presented below):
>
> lm(formula = y ~ ns(x, 4))
>
> Coefficients:
> (Intercept) ns(x, 4)1 ns(x, 4)2 ns(x, 4)3
> -0.08108135 0.08057826 0.07411367 0.1566252
>
> ns(x, 4)4
> 0.0940209
>
> if the knots are specified as 5, there are 5 + 1 Intercept coefficients.
>
> My Question: How to interpret these coefficients. In a spline fit there
> have to be a different polynomial fit for different knots. therefore how
> to interpret these coefficients.
--
Brian D. Ripley, ripley@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
|