[R] The explanation of ns() with df =2
Michael Friendly
friendly at yorku.ca
Tue Apr 15 14:18:40 CEST 2014
No, the curves on each side of the know are cubics, joined
so they are continuous. Se the discussion in \S 17.2 in
Fox's Applied Regression Analysis.
On 4/15/2014 4:14 AM, Xing Zhao wrote:
> 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.
>
> How to think about this problem?
>
> 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"
>
--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept. & Chair, Quantitative Methods
York University Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele Street Web: http://www.datavis.ca
Toronto, ONT M3J 1P3 CANADA
More information about the R-help
mailing list