[R] splines

Thomas Lumley tlumley at u.washington.edu
Thu May 2 18:48:16 CEST 2002

On Thu, 2 May 2002, crambe Christophe wrote:

> I've got a problem with the R function spline.des.
> I use the following arguments:
>     x_seq(0,1,length=200)
>     knot_quantile(x,(1:8)/9)
>     ord_3
>     k_sort(c(rep(range(x),ord,knot)))
>     derivs_rep(2,200)
> When I do spline.des(k,x,ord,derivs)$design on Splus and on R, I don't
> have the same results.
> However, if I take an order ord=4 (ie a spline of degree 3), then, I
> have the same results on Splus and R.

I do get the same results --

Warning message:
Numerical expression has 8 elements: only the first used in: 1:length.out

Warning messages:
  Condition has 8 elements: only the first used in: if(length.out > 0)
        Recall(x, ceiling(length.out/n))[1:length.out] else x[0]

and assuming you meant


I then get the same result from both packages except for the last line of
the matrix, which is all zero in R but is equal to the previous line in

This appears to be a rounding error due to having multiple knots `exactly'
at the maximum value -- if the knot is moved very slightly to the right
then the packages agree again.


Thomas Lumley			Asst. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list