rspline

Spline in R terms and wording - degree of the polynom - degree of freedom - degree of continuity - basisspline


I am creating a spline in R with the following function:

spline_model <- lm(sales ~ bs(data_clean$visits, df = 3, knots = 3)+ data_clean$discount -1, data = data_clean)

But I am bit confused with the wording and the terms which I am reading in the scientific literature and in the help of R. There are

Additionaly there is a basis spline which is used by my function bs. But what is so special about the basis spline?

Can you help me please to bring more clarity in the different terms and how to influence them in R?

Thank you!


Solution

  • I have found an answer: degree of polynom is normally 3 for a cubic polynom. This is how crazy the lines are, e.g. 1 is linear. More than 3 is not neccessarry. In R parameter degree. degree of freedom: This is knots + degree of polynom. If degree of polynom is 3 than you need to have at least degree of freedom 3. You can rather chose knots or degree of freedom because they are connected with each other. Parameter in R is df. degree of continuity, I did not found. But knots are the number or positions of the knots in the spline. Parameter in R is knots.