Dear Maintainer,

Thanks for the excellent package splines. I am writing this email to request 
you to consider a suggestion I have with regards to the function ns.


While trying to rework an example from a textbook, I couldn't call ns with 
appropriate arguments to reproduce the results. The package documentation also 
couldn't help me find the problem. Finally, I found a stack exchange question 
(https://stats.stackexchange.com/questions/588769/natural-splines-in-r-with-ns) 
 which helped me understand the problem - the default values of boundary knots 
are not useful. The problem is described in the stack exchange question, which 
I request you to kindly read.


My suggestion is to change the default value of the argument Boundary.knots to 
NULL and calculate its values from  the extreme values of the argument knots 
inside the function body if it is NULL and otherwise to keep whatever numerical 
value it is assigned at call.


I think it is more intuitive to the user to specify one set of knots assuming 
that its minimum and maximum values would be used as the knots beyond which 
regression would be linear rather than to know that the function automatically 
calculates boundary knots which are not appropriate and so he needs to override 
them.


Just so that I am clear, an example. Assume that my variable *alcohol*  has 
values from 1 to 100 and I want to specify natural splines at knots 20,40 and 
60, expecting linearity would hold below 20 and above 60. Currently, I have to 
specify knots as 40 and boundary knots as 20 and 60 as ns(alcohol , knots = 
c(40), Boundary.knots = c(20,60))

If I incorrectly assume that correct values of boundary knots are calculated by 
default, I will specify knots as 20,40 and 60 as ns(alcohol , knots = 
c(20,40,60)) and get incorrect values for boundary knots as 1 and 100. (I have 
done this and the stack exchange post shows that I am not alone).


Hope my suggestion will be considered,


Thanks,
ajith

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to