Examples for 'splines::periodicSpline'


Create a Periodic Interpolation Spline

Aliases: periodicSpline

Keywords: models

### ** Examples

require(graphics); require(stats)
xx <- seq( -pi, pi, length.out = 16 )[-1]
yy <- sin( xx )
frm <- data.frame( xx, yy )
pispl <- periodicSpline( xx, yy, period = 2 * pi)
## No test: 
pispl
bSpline representation of spline for yy ~ xx
     -3.97935      -3.56047      -3.14159      -2.72271      -2.30383 
           NA            NA            NA            NA  2.747662e-16 
     -1.88496      -1.46608      -1.04720      -0.62832      -0.20944 
-4.188059e-01 -7.651964e-01 -9.792775e-01 -1.024033e+00 -8.917232e-01 
      0.20944       0.62832       1.04720       1.46608       1.88496 
-6.052268e-01 -2.140811e-01  2.140811e-01  6.052268e-01  8.917232e-01 
      2.30383       2.72271       3.14159       3.56047       3.97935 
 1.024033e+00  9.792775e-01  7.651964e-01  4.188059e-01  2.747662e-16 
      4.39823       4.81711 
-4.188059e-01 -7.651964e-01 
## End(No test)
pispl2 <- periodicSpline( yy ~ xx, frm, period = 2 * pi )
stopifnot(all.equal(pispl, pispl2))  # pispl and pispl2 are the same

plot( pispl )          # displays over one period
points( yy ~ xx, col = "brown")
plot of chunk example-splines-periodicSpline-1
plot( predict( pispl, seq(-3*pi, 3*pi, length.out = 101) ), type = "l" )
plot of chunk example-splines-periodicSpline-1

[Package splines version 4.2.3 Index]