The packageslasso implements the smooth LASSOestimator (S-LASSO) for the Function-on-Function linear regression modelproposed by Centofanti et al. (2020). The S-LASSO estimator is able toincrease the interpretability of the model, by better locating regionswhere the coefficient function is zero, and to smoothly estimatenon-zero values of the coefficient function. The sparsity of theestimator is ensured by a functional LASSO penalty, which pointwiseshrinks toward zero the coefficient function, while the smoothness isprovided by two roughness penalties that penalize the curvature of thefinal estimator. The package comprises two main functionsslasso.fr andslasso.fr_cv. The formerimplements the S-LASSO estimator for fixed tuning parameters of thesmoothness penaltiesλs andλt, and tuning parameter of the functionalLASSO penaltyλL. The latter executes theK-fold cross-validation procedure described in Centofanti et al. (2020)to chooseλL,λs, andλt.
The development version can be installed fromGitHub with:
# install.packages("devtools")devtools::install_github("unina-sfere/slasso")This is a basic example which shows you how to apply the two mainfunctionsslasso.fr andslasso.fr_cv on asynthetic dataset generated as described in the simulation study ofCentofanti et al. (2020).
We start by loading and attaching theslassopackage.
library(slasso)Then, we generate the synthetic dataset and build the basis functionsets as follows.
data<-simulate_data("Scenario II",n_obs=500)X_fd=data$X_fdY_fd=data$Y_fddomain=c(0,1)n_basis_s<-30n_basis_t<-30breaks_s<-seq(0,1,length.out = (n_basis_s-2))breaks_t<-seq(0,1,length.out = (n_basis_t-2))basis_s<- fda::create.bspline.basis(domain,breaks=breaks_s)basis_t<- fda::create.bspline.basis(domain,breaks=breaks_t)To applyslasso.fr_cv, sequences ofλL,λs, andλt should be defined.
lambda_L_vec=10^seq(0,1,by=0.1)lambda_s_vec=10^seq(-6,-5)lambda_t_vec=10^seq(-5,-5)And, then,slasso.fr_cv is executed.
mod_slasso_cv<-slasso.fr_cv(Y_fd = Y_fd,X_fd=X_fd,basis_s=basis_s,basis_t=basis_t,lambda_L_vec = lambda_L_vec,lambda_s_vec = lambda_s_vec,lambda_t_vec =lambda_t_vec,max_iterations=1000,K=10,invisible=1,ncores=12)The results are plotted.
plot(mod_slasso_cv)
By using themodel selection method described in Centofanti et al. (2020), theoptimal values ofλL,λs, andλt,are 3.98, 10 − 5, and 10 − 5, respectively.
Finally,sasfclust is applied withλL,λs, andλt fixed to their optimal values.
mod_slasso<-slasso.fr(Y_fd = Y_fd,X_fd=X_fd,basis_s=basis_s,basis_t=basis_t,lambda_L = mod_slasso_cv$lambda_opt_vec[1],lambda_s = mod_slasso_cv$lambda_opt_vec[2],lambda_t = mod_slasso_cv$lambda_opt_vec[3],invisible=1,max_iterations=1000)The resulting estimator is plotted as follows.
plot(mod_slasso)