Last chance! 50% off unlimited learning
Sale ends in
This function implements the Improved Algorithm for Sparse Semiparametric Multi-functional Regression (IASSMR) with kNN estimation. This algorithm is specifically designed for estimating multi-functional partial linear single-index models, which incorporate multiple scalar variables and a functional covariate as predictors. These scalar variables are derived from the discretisation of a curve and have linear effects while the functional covariate exhibits a single-index effect.
IASSMR is a two-stage procedure that selects the impact points of the discretised curve and estimates the model. The algorithm employs a penalised least-squares regularisation procedure, integrated with kNN estimation using Nadaraya-Watson weights. It uses B-spline expansions to represent curves and eligible functional indexes. Additionally, it utilises an objective criterion (criterion
) to determine the initial number of covariates in the reduced model (w.opt
), the number of neighbours (k.opt
), and the penalisation parameter (lambda.opt
).
IASSMR.kNN.fit(x, z, y, train.1 = NULL, train.2 = NULL,
seed.coeff = c(-1, 0, 1), order.Bspline = 3, nknot.theta = 3, knearest = NULL,
min.knn = 2, max.knn = NULL, step = NULL, range.grid = NULL,
kind.of.kernel = "quad", nknot = NULL, lambda.min = NULL, lambda.min.h = NULL,
lambda.min.l = NULL, factor.pn = 1, nlambda = 100, vn = ncol(z), nfolds = 10,
seed = 123, wn = c(10, 15, 20), criterion = "GCV", penalty = "grSCAD",
max.iter = 1000, n.core = NULL)
The matched call.
Estimated scalar response.
Differences between y
and the fitted.values
.
w.opt
, lambda.opt
, vn.opt
and k.opt
are used).
Coefficients of w.opt
, lambda.opt
, vn.opt
and k.opt
are used): a vector of length(order.Bspline+nknot.theta)
.
Indexes of the non-zero
Selected number of nearest neighbours (when w.opt
is considered).
Selected initial number of covariates in the reduced model.
Selected value of the penalisation parameter w.opt
is considered).
Value of the criterion function considered to select w.opt
, lambda.opt
, vn.opt
and k.opt
.
Selected value of vn
in the second step (when w.opt
is considered).
Estimate of wn
.
Estimate of wn
(i.e. its coefficients in the B-spline basis).
Indexes of the non-zero linear coefficients after the step 2 of the method for each value of the sequence wn
.
Selected number of neighbours in the second step of the algorithm for each value of the sequence wn
.
Optimal value of the criterion function in the second step for each value of the sequence wn
.
Selected value of penalisation parameter in the second step for each value of the sequence wn
.
Indexes of the covariates (in the entire set of wn
.
Estimate of wn
.
Estimate of wn
(i.e. its coefficients in the B-spline basis).
Selected number of neighbours in the first step of the algorithm for each value of the sequence wn
.
Optimal value of the criterion function in the first step for each value of the sequence wn
.
Selected value of penalisation parameter in the first step for each value of the sequence wn
.
Indexes of the covariates (in the whole set of wn
.
Indexes of the non-zero linear coefficients after the step 1 of the method for each value of the sequence wn
.
Matrix containing the observations of the functional covariate collected by row (functional single-index component).
Matrix containing the observations of the functional covariate that is discretised collected by row (linear component).
Vector containing the scalar response.
Positions of the data that are used as the training sample in the 1st step. The default setting is train.1<-1:ceiling(n/2)
.
Positions of the data that are used as the training sample in the 2nd step. The default setting is train.2<-(ceiling(n/2)+1):n
.
Vector of initial values used to build the set Details
). The coefficients for the B-spline representation of each eligible functional index seed.coeff
. The default is c(-1,0,1)
.
Positive integer giving the order of the B-spline basis functions. This is the number of coefficients in each piecewise polynomial segment. The default is 3.
Positive integer indicating the number of regularly spaced interior knots in the B-spline expansion of
Vector of positive integers containing the sequence in which the number of nearest neighbours k.opt
is selected. If knearest=NULL
, then knearest <- seq(from =min.knn, to = max.knn, by = step)
.
A positive integer that represents the minimum value in the sequence for selecting the number of nearest neighbours k.opt
. This value should be less than the sample size. The default is 2.
A positive integer that represents the maximum value in the sequence for selecting number of nearest neighbours k.opt
. This value should be less than the sample size. The default is max.knn <- n%/%5
.
A positive integer used to construct the sequence of k-nearest neighbours as follows: min.knn, min.knn + step, min.knn + 2*step, min.knn + 3*step,...
. The default value for step
is step<-ceiling(n/100)
.
Vector of length 2 containing the endpoints of the grid at which the observations of the functional covariate x
are evaluated (i.e. the range of the discretisation). If range.grid=NULL
, then range.grid=c(1,p)
is considered, where p
is the discretisation size of x
(i.e. ncol(x))
.
The type of kernel function used. Currently, only Epanechnikov kernel ("quad"
) is available.
Positive integer indicating the number of interior knots for the B-spline expansion of the functional covariate. The default value is (p - order.Bspline - 1)%/%2
.
The smallest value for lambda (i. e., the lower endpoint of the sequence in which lambda.opt
is selected), as fraction of lambda.max
.
The defaults is lambda.min.l
if the sample size is larger than factor.pn
times the number of linear covariates and lambda.min.h
otherwise.
The lower endpoint of the sequence in which lambda.opt
is selected if the sample size is smaller than factor.pn
times the number of linear covariates. The default is 0.05.
The lower endpoint of the sequence in which lambda.opt
is selected if the sample size is larger than factor.pn
times the number of linear covariates. The default is 0.0001.
Positive integer used to set lambda.min
. The default value is 1.
Positive integer indicating the number of values in the sequence from which lambda.opt
is selected. The default is 100.
Positive integer or vector of positive integers indicating the number of groups of consecutive variables to be penalised together. The default value is vn=ncol(z)
, resulting in the individual penalization of each scalar covariate.
Number of cross-validation folds (used when criterion="k-fold-CV"
). Default is 10.
You may set the seed for the random number generator to ensure reproducible results (applicable when criterion="k-fold-CV"
is used). The default seed value is 123.
A vector of positive integers indicating the eligible number of covariates in the reduced model. For more information, refer to the section Details
. The default is c(10,15,20)
.
The criterion used to select the tuning and regularisation parameters: wn.opt
, lambda.opt
and k.opt
(also vn.opt
if needed). Options include "GCV"
, "BIC"
, "AIC"
, or "k-fold-CV"
. The default setting is "GCV"
.
The penalty function applied in the penalised least-squares procedure. Currently, only "grLasso" and "grSCAD" are implemented. The default is "grSCAD".
Maximum number of iterations allowed across the entire path. The default value is 1000.
Number of CPU cores designated for parallel execution. The default is n.core<-availableCores(omit=1)
.
German Aneiros Perez german.aneiros@udc.es
Silvia Novo Diaz snovo@est-econ.uc3m.es
The multi-functional partial linear single-index model (MFPLSIM) is given by the expression
In the MFPLSIM, it is assumed that only a few scalar variables from the set
In this function, the MFPLSIM is fitted using the IASSMR. The IASSMR is a two-step procedure. For this, we divide the sample into two independent subsamples, each asymptotically half the size of the original (
Note that these two subsamples are specified in the program through the arguments train.1
and train.2
. The superscript
To explain the algorithm, we assume that the number
First step. The FASSMR (see FASSMR.kNN.fit
) combined with kNN estimation is applied using only the subsample
Consider a subset of the initial wn
(which contains a sequence of eligible sizes).
Consider the following reduced model, which involves only the sfplsim.kNN.fit
, which requires the remaining arguments (see sfplsim.kNN.fit
). The estimates obtained after that are the outputs of the first step of the algorithm.
Second step. The variables selected in the first step, along with those in their neighborhood, are included. The penalised least-squares procedure, combined with kNN estimation, is carried out again considering only the subsample
Consider a new set of variables:
Consider the following model, which involves only the linear covariates belonging to sfplsim.kNN.fit
.
The outputs of the second step are the estimates of the MFPLSIM. For further details on this algorithm, see Novo et al. (2021).
Remark: If the condition
The function supports parallel computation. To avoid it, we can set n.core=1
.
Novo, S., Vieu, P., and Aneiros, G., (2021) Fast and efficient algorithms for sparse semiparametric bi-functional regression. Australian and New Zealand Journal of Statistics, 63, 606--638, tools:::Rd_expr_doi("https://doi.org/10.1111/anzs.12355").
See also sfplsim.kNN.fit, predict.IASSMR.kNN
, plot.IASSMR.kNN
and FASSMR.kNN.fit
.
Alternative method IASSMR.kernel.fit
# \donttest{
data(Sugar)
y<-Sugar$ash
x<-Sugar$wave.290
z<-Sugar$wave.240
#Outliers
index.y.25 <- y > 25
index.atip <- index.y.25
(1:268)[index.atip]
#Dataset to model
x.sug <- x[!index.atip,]
z.sug<- z[!index.atip,]
y.sug <- y[!index.atip]
train<-1:216
ptm=proc.time()
fit<- IASSMR.kNN.fit(x=x.sug[train,],z=z.sug[train,], y=y.sug[train],
train.1=1:108,train.2=109:216,nknot.theta=2,lambda.min.h=0.07,
lambda.min.l=0.07, max.knn=20, nknot=20,criterion="BIC", max.iter=5000)
proc.time()-ptm
fit
names(fit)
# }
Run the code above in your browser using DataLab