I'm fitting a natural basis spline on a data set of the form:

splineModel=lm(dist~bs(speed, df=3), data=cars)

using bs function of spline package. I would like to know whether is possible to print the actual spline equations fitted (the tracing) within each knot. I would like to have the coefficients of all piecewise fitted polynomials.

  • $\begingroup$ Could you provide more details on exactly what you want? What you achieve using bs as above essentially amounts to evaluations of B-splines at the data points to form a design matrix, which is used for the estimation of the coefficients for the B-spline basis expansion. Using the predict function it is pretty easy to get the resulting fitted curve at the data points as well as at new points if desired, but it does not give you any equations. $\endgroup$ – NRH Nov 8 '11 at 19:42
  • $\begingroup$ I would like to have the equations itself $\endgroup$ – Giorgio Spedicato Sep 7 '13 at 13:03
  • $\begingroup$ This issue has been solved on Stack Overflow: Reparametrize fitted regression spline as piecewise polynomials and export polynomial coefficients $\endgroup$ – 李哲源 Aug 9 '18 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.