Goodmorning, This is a documentation related question about the B-spline function in R. In the help file it is stated that: "df degrees of freedom; one can specify df rather than knots; bs() then chooses df-degree-1 knots at suitable quantiles of x (which will ignore missing values)." So if one were to specify a spline with 6 degrees of freedom (and no intercept) then a basis with 6-3-1 =2 internal knots should be created. However this is not what happens: > library(splines) > s1<-bs(women$height, df = 6,deg=3) > s2<-bs(women$height, df = 6,deg=2) > > attributes(s1)$knots 25% 50% 75% 61.5 65.0 68.5 > attributes(s2)$knots 20% 40% 60% 80% 60.8 63.6 66.4 69.2 > i.e. basis is created with an extra knot i.e. bs() chooses df-degree internal knots The documentation of "ns" states that: " .... ns() then chooses df - 1 - intercept knots ..." suggesting that the spline functions create the basis with df-degree internal knots if no intercept is specified but df-degree-1 internal knots if the caller explicitly asks for an intercept. > s1<-bs(women$height, df = 6,deg=3,intercept=T) > s2<-bs(women$height, df = 6,deg=2,intercept=T) > > attributes(s1)$knots 33.33333% 66.66667% 62.66667 67.33333 > attributes(s2)$knots 25% 50% 75% 61.5 65.0 68.5 Is it possible to change the documentation of these functions to reflect their actual behaviour. For example something like the following: "df degrees of freedom; one can specify df rather than knots; bs() then chooses df-degree-1 knots at suitable quantiles of x (which will ignore missing values) if the intercept argument is TRUE and df-degree if intercept=FALSE." Christos Argyropoulos _________________________________________________________________ Hotmail: Trusted email with Microsoft’s powerful SPAM protection.
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.