# Getting spline coefficients in R

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.

• 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. – NRH Nov 8 '11 at 19:42
• I would like to have the equations itself – Giorgio Spedicato Sep 7 '13 at 13:03
• This issue has been solved on Stack Overflow: Reparametrize fitted regression spline as piecewise polynomials and export polynomial coefficients – 李哲源 Aug 9 '18 at 15:07