The method provides graphical visualization of a Splinets
-class object. The method plot a
Splinets
in a cartesian or a polar coordinate if it is a regular splines or a periodic splines, respectively.
Usage
# S4 method for class 'Splinets'
plot(
object,
x = NULL,
sID = NULL,
vknots = TRUE,
type = "stnd",
mrgn = 2,
lwd = 2,
...
)
Arguments
- object
Splinets
object;- x
vector, specifying where the splines will be evaluated for the plots;
- sID
vector, specifying indices of the splines to be plotted;
- vknots
logic, indicates if auxiliary vertical lines will be added to highlight the positions of knots; The default is
TRUE
.- type
string, controls the layout of graphs; The following options are available
"stnd"
– ifobject@type="dspnt"
or="spnt"
, then the plots are over the dyadic net of supports, other types of the bases are on a single plot with information about the basis printed out,"simple"
– all the objects are plotted in a single plot,"dyadic"
– ifobject@type="sp"
is not true (unstructured collection of splines), then the plot is over the dyadic net of supports.
- mrgn
number, specifying the margin size in the dyadic structure plot;
- lwd
positive integer, the line width;
- ...
other standard graphical parameters can be passed;
Details
The standard method of plotting splines in a Splinet
-object.
It plots a single graph with all splines in the object except if the field type
of the
object represents a splinet. In the latter case, the default is the (dyadic) net plot of
the basis. The string argument type
can overide this to produce a plot that does not use the dyadic net.
Most of the standard graphical parameters can be passed to this function.
References
Liu, X., Nassar, H., Podg\(\mbox{\'o}\)rski, K. "Dyadic diagonalization of positive definite band matrices and efficient B-spline orthogonalization." Journal of Computational and Applied Mathematics (2022) <https://doi.org/10.1016/j.cam.2022.114444>.
Podg\(\mbox{\'o}\)rski, K. (2021)
"Splinets
– splines through the Taylor expansion, their support sets and orthogonal bases." <arXiv:2102.00733>.
Nassar, H., Podg\(\mbox{\'o}\)rski, K. (2023) "Splinets 1.5.0 – Periodic Splinets." <arXiv:2302.07552>
See also
evspline
for manually evaluating splines in a Splinet
-object;
Splinets-class
for the definition of the Splinet
-class;
lines,Splinets-method
for adding graphs to existing plots;
Examples
#-----------------------------------------------------#
#-------------------Ploting splinets------------------#
#-----------------------------------------------------#
#Constructed splines
n=25; xi=sort(runif(n+2)); xi[1]=0; xi[n+2]=1; k=3
supp=list(t(c(2,12)),t(c(4,20)),t(c(6,25))) #defining support ranges for three splines
#Initial random matrices of the derivative for each spline
SS1=matrix(rnorm((supp[[1]][1,2]-supp[[1]][1,1]+1)*(k+1)),ncol=(k+1))
SS2=matrix(rnorm((supp[[2]][1,2]-supp[[2]][1,1]+1)*(k+1)),ncol=(k+1))
SS3=matrix(rnorm((supp[[3]][1,2]-supp[[3]][1,1]+1)*(k+1)),ncol=(k+1))
spl=construct(xi,k,SS1,supp[[1]]) #constructing the first correct spline
#>
#> Using method RRM to correct the derivative matrix entries.
#>
#>
#> DIAGNOSTIC CHECK of a SPLINETS object
#>
#> THE KNOTS:
#>
#>
#> THE SUPPORT SETS:
#>
#>
#>
#> THE DERIVATIVES AT THE KNOTS:
#>
#> The boundary zero conditions are not satisfied for spline 1 in the input 'Splinets' object.
#> Correction of the first and last rows of the derivative matrices over the support component 1 of spline 1 in the output 'Splinets' object.
#>
#> Spline 1 support 1 's highest derivative at the central knot is not zero.
#> Now it is set to zero.
#>
#> The matrix of derivatives at the knots for spline 1 , support 1 does not satisfy the splie conditions (up to the accuracy set in SLOT 'epsilon').
#> The computed standard error per matrix entry is 1.13763 .
#>
#>
#> Correction of the LHS part of the matrix
#> Correction of the RHS part of the matrix
#> Correction of the LHS part of the matrix
#> Correction of the RHS part of the matrix
#> The output object Spline 1 support 1 has the derivative matrix corrected by the RRM method.
#> The matrix derivative is now corrected by method RRM .
nspl=construct(xi,k,SS2,supp[[2]],'CRFC')
#>
#> Using method CRFC to correct the derivative matrix entries.
#>
#>
#> DIAGNOSTIC CHECK of a SPLINETS object
#>
#> THE KNOTS:
#>
#>
#> THE SUPPORT SETS:
#>
#>
#>
#> THE DERIVATIVES AT THE KNOTS:
#>
#> The boundary zero conditions are not satisfied for spline 1 in the input 'Splinets' object.
#> Correction of the first and last rows of the derivative matrices over the support component 1 of spline 1 in the output 'Splinets' object.
#>
#> Spline 1 support 1 's highest derivative at the central knot is not zero.
#> Now it is set to zero.
#>
#> The matrix of derivatives at the knots for spline 1 , support 1 does not satisfy the splie conditions (up to the accuracy set in SLOT 'epsilon').
#> The computed standard error per matrix entry is 1.025867 .
#>
#>
#> Correction of the LHS part of the matrix
#> Correction of the RHS part of the matrix
#> Correction of the LHS part of the matrix
#> Correction of the RHS part of the matrix
#> The output object Spline 1 support 1 has the derivative matrix corrected by the RRM method.The zero boundary conditions are not satisfied.
#> The correction of the first and last rows of the derivative matrix has been made.
#>
#>
#> The highest order derivative at the central knot is not equal to zero.
#> It has been made equal to zero now.
#>
#> Correction of the LHS part of the matrix
#> Correction of the RHS part of the matrix
#> The matrix derivative is now corrected by method CRFC .
spl=gather(spl,nspl) #the second and the first ones
nspl=construct(xi,k,SS3,supp[[3]],'CRLC')
#>
#> Using method CRLC to correct the derivative matrix entries.
#>
#>
#> DIAGNOSTIC CHECK of a SPLINETS object
#>
#> THE KNOTS:
#>
#>
#> THE SUPPORT SETS:
#>
#>
#>
#> THE DERIVATIVES AT THE KNOTS:
#>
#> The boundary zero conditions are not satisfied for spline 1 in the input 'Splinets' object.
#> Correction of the first and last rows of the derivative matrices over the support component 1 of spline 1 in the output 'Splinets' object.
#>
#> Spline 1 , support 1 - highest derivative is not symmetric at the center (equal values at the two central knots).
#> The two values have been made equal by averaging.
#>
#> The matrix of derivatives at the knots for spline 1 , support 1 does not satisfy the splie conditions (up to the accuracy set in SLOT 'epsilon').
#> The computed standard error per matrix entry is 1.478627 .
#>
#>
#> Correction of the LHS part of the matrix
#> Correction of the RHS part of the matrix
#> Correction of the LHS part of the matrix
#> There are less than 5 knots, the first 2 entries of the 5 nd row counting from the end in the input will be changed in the output.
#>
#>
#> Correction of the RHS part of the matrix
#> There are less than 5 knots, the first 2 entries of the 5 nd row counting from the end in the input will be changed in the output.
#>
#>
#> Correction of the LHS part of the matrix
#> Correction of the RHS part of the matrix
#> The output object Spline 1 support 1 has the derivative matrix corrected by the RRM method.The zero boundary conditions are not satisfied.
#> The correction of the first and last rows of the derivative matrix has been made.
#>
#>
#> The highest order derivative is not symmetrically defined at the center.
#> The values at the two central knots should be equal.
#> The highest order derivative values at the two central knots
#> have been made equal by averaging the two central values.
#>
#> Correction of the LHS part of the matrix
#> Correction of the RHS part of the matrix
#> The matrix derivative is now corrected by method CRLC .
spl=gather(spl,nspl) #the third is added
plot(spl)
plot(spl,sID=c(1,3))
plot(spl,sID=2)
t = seq(0,0.5,length.out = 1000)
plot(spl, t, sID = 1)
#Random splines
n=17; k=4; xi=sort(runif(n+2)); xi[1]=0; xi[n+2]=1
S=matrix(rnorm((n+2)*(k+1)),ncol=(k+1))
spl=construct(xi,k,S)
#>
#> Using method RRM to correct the derivative matrix entries.
#>
#>
#> DIAGNOSTIC CHECK of a SPLINETS object
#>
#> THE KNOTS:
#>
#>
#> THE SUPPORT SETS:
#>
#> The support sets for the splines are equal to the entire range of knots.
#>
#>
#> THE DERIVATIVES AT THE KNOTS:
#>
#> The boundary zero conditions are not satisfied for spline 1 in the input 'Splinets' object.
#> Correction of the first and last rows of the derivative matrices are made in the output 'Splinets' object.
#>
#> The spline 1 'ths highest derivative at the central knot is zero.
#> Now it is set to zero.
#>
#> The derivative matrix for spline 1 does not satisfy the smoothness conditions (up to the accuracy SLOT 'epsilon').
#> The standard error per matrix entry is 1.302927 .
#>
#>
#> Correction of the LHS part of the matrix
#> There are less than 6 knots, the first 1 entries of the 6 nd row counting from the end in the input will be changed in the output.
#>
#>
#> Correction of the RHS part of the matrix
#> There are less than 6 knots, the first 1 entries of the 6 nd row counting from the end in the input will be changed in the output.
#>
#>
#> Correction of the LHS part of the matrix
#> Correction of the RHS part of the matrix
#> The output object has the derivative matrix corrected by the RRM method.
#>
#> The matrix derivative is now corrected by method RRM .
plot(spl,main="Mean Spline",lty=2,lwd=2,xlab='')
RS=rspline(spl,5)
plot(RS,main="Random splines around the mean spline",ylim=3*range(spl@der[[1]][,1]) )
lines(spl,col='red',lwd=4,lty=2)
#Periodic splines
xi = seq(0, 1, length.out = 25)
so = splinet(xi, periodic = TRUE)
plot(so$bs)
plot(so$os)
plot(so$bs,type= "dyadic")
plot(so$bs, sID=c(4,6))
plot(so$os, type="simple",sID=c(4,6))