# [R] The explanation of ns() with df =2

Xing Zhao zhaoxing at uw.edu
Tue Apr 15 10:14:40 CEST 2014

```Dear all

I understand the definition of Natural Cubic Splines are those with
linear constraints on the end points. However, it is hard to think
about how this can be implement when df=2. df=2 implies there is just
one knot, which, according the the definition, the curves on its left
and its right should be both be lines. This means the whole line
should be a line. But when making some fits. the result still looks
like 2nd order polynomial.

Thanks
Xing

ns(1:15,df =2)
1           2
[1,] 0.0000000  0.00000000
[2,] 0.1084782 -0.07183290
[3,] 0.2135085 -0.13845171
[4,] 0.3116429 -0.19464237
[5,] 0.3994334 -0.23519080
[6,] 0.4734322 -0.25488292
[7,] 0.5301914 -0.24850464
[8,] 0.5662628 -0.21084190
[9,] 0.5793481 -0.13841863
[10,] 0.5717456 -0.03471090
[11,] 0.5469035  0.09506722
[12,] 0.5082697  0.24570166
[13,] 0.4592920  0.41197833
[14,] 0.4034184  0.58868315
[15,] 0.3440969  0.77060206
attr(,"degree")
[1] 3
attr(,"knots")
50%
8
attr(,"Boundary.knots")
[1]  1 15
attr(,"intercept")
[1] FALSE
attr(,"class")
[1] "ns"     "basis"  "matrix"

```