subsample {Splinets} | R Documentation |
Subsampling from a set of splines
Description
The function constructs a Splinets
-object that is made of subsampled
elements of the input Splinets
-object.
The input objects have to be of the same order and over the same knots.
Usage
subsample(Sp, ss)
Arguments
Sp |
|
ss |
vector of integers, the coordinates from |
Details
The output Splinet
-object made of subsampled splines is always is of the regular type, i.e. SLOT type='sp'
.
Value
An Splinets
-object containing length(ss)
splines that are selected from the input object./
References
Liu, X., Nassar, H., Podgrski, 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>.
Podgrski, K. (2021)
"
Splinets
– splines through the Taylor expansion, their support sets and orthogonal bases." <arXiv:2102.00733>.
Nassar, H., Podgrski, K. (2023) "Splinets 1.5.0 – Periodic Splinets." <arXiv:2302.07552>
See Also
is.splinets
for diagnostic of Splinets
-objects;
construct
for constructing such a Splinets
-object;
gather
for combining Splinets
-objects;
refine
for refinment of a spline to a larger number of knots;
plot,Splinets-method
for plotting Splinets
-objects;
Examples
#-----------------------------------------------------#
#---------------------Subsampling---------------------#
#-----------------------------------------------------#
#Example with different support ranges, the 3rd order
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
set.seed(5)
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
nspl=construct(xi,k,SS2,supp[[2]],'CRFC')
#See 'gather' function for more details on what follows
spl=gather(spl,nspl) #the second and the first ones
nspl=construct(xi,k,SS3,supp[[3]],'CRLC')
spl=gather(spl,nspl) #the third is added
#Replicating by subsampling with replacement
sz=length(spl@der)
ss=sample(1:sz,size=10,rep=TRUE)
spl=subsample(spl,ss)
is.splinets(spl)[[1]]
spl@supp
spl@der
#Subsampling without replacements
ss=c(3,8,1)
sspl=subsample(spl,ss)
sspl@supp
sspl@der
is.splinets(sspl)[[1]]
#A single spline sampled from a 'Splinets' object
is.splinets(subsample(sspl,1))