4
$\begingroup$

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.

$\endgroup$
3
  • $\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, 2011 at 19:42
  • $\begingroup$ I would like to have the equations itself $\endgroup$ Sep 7, 2013 at 13:03
  • 1
    $\begingroup$ This issue has been solved on Stack Overflow: Reparametrize fitted regression spline as piecewise polynomials and export polynomial coefficients $\endgroup$
    – Zheyuan Li
    Aug 9, 2018 at 15:07

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.