sasfclust_cv {sasfunclust} | R Documentation |
Cross-validation for sasfclust
Description
K-fold cross-validation procedure to choose the number of clusters and the tuning parameters for the sparse and smooth functional clustering (SaS-Funclust) method (Centofanti et al., 2021).
Usage
sasfclust_cv(
X = NULL,
timeindex = NULL,
curve = NULL,
grid = NULL,
q = 30,
lambda_l_seq = 10^seq(-1, 2),
lambda_s_seq = 10^seq(-5, -3),
G_seq = 2,
tol = 10^-7,
maxit = 50,
par_LQA = list(eps_diff = 1e-06, MAX_iter_LQA = 200, eps_LQA = 1e-05),
plot = FALSE,
trace = FALSE,
init = "kmeans",
varcon = "diagonal",
lambda_s_ini = NULL,
K_fold = 5,
X_test = NULL,
grid_test = NULL,
m1 = 1,
m2 = 0,
m3 = 1,
ncores = 1
)
Arguments
X |
For functional data observed over a regular grid: a matrix of where the rows must correspond to argument values and columns to replications.
For functional data observed over an irregular grid: a vector of length |
timeindex |
A vector of length |
curve |
A vector of length |
grid |
The vector of time points where the curves are sampled.
For Functional data observed over an irregular grid, |
q |
The dimension of the set of B-spline functions. |
lambda_l_seq |
Sequence of tuning parameter of the functional adaptive pairwise fusion penalty (FAPFP). |
lambda_s_seq |
Sequence of tuning parameter of the smoothness penalty. |
G_seq |
Sequence of number of clusters. |
tol |
The tolerance for the stopping condition of the expectation conditional maximization (ECM) algorithms.
The algorithm stops when the log-likelihood difference between two consecutive iterations is less or equal than |
maxit |
The maximum number of iterations allowed in the ECM algorithm. |
par_LQA |
A list of parameters for the local quadratic approximation (LQA) in the ECM algorithm.
|
plot |
If TRUE, the estimated cluster means are plotted at each iteration of the ECM algorithm. Default is FALSE. |
trace |
If TRUE, information are shown at each iteration of the ECM algorithm. Default is FALSE. |
init |
It is the way to initialize the ECM algorithm. There are three ways of initialization: "kmeans", "model-based", and "hierarchical", that provide initialization through the k-means algorithm, model-based clustering based on parameterized finite Gaussian mixture model, and hierarchical clustering, respectively. Default is "kmeans". |
varcon |
A vector of character strings indicating the type of coefficient covariance matrix. Three values are allowed: "full", "diagonal", and "equal". "full" means unrestricted cluster coefficient covariance matrices allowed to be different among clusters. "diagonal" means diagonal cluster coefficient covariance matrices that are equal among clusters. "equal" means diagonal cluster coefficient covariance matrices, with equal diagonal entries, that are equal among clusters. Default is "diagonal". |
lambda_s_ini |
The tuning parameter used to obtain the functional data through smoothing B-splines before applying the initialization algorithm. If NULL a Generalized cross validation procedure is used as described in Ramsay (2005). Default is NULL. |
K_fold |
Number of folds. Default is 5. |
X_test |
Only for functional data observed over a regular grid, a matrix where the rows must correspond to argument values and columns to replications of the test set. Default in NULL. |
grid_test |
The vector of time points where the test set curves are sampled. Default is NULL. |
m1 |
The m-standard deviation rule parameter to choose |
m2 |
The m-standard deviation rule parameter to choose |
m3 |
The m-standard deviation rule parameter to choose |
ncores |
If |
Value
A list containing the following arguments:
G_opt
: The optimal number of clusters.
lambda_l_opt
: The optimal tuning parameter of the FAPFP.
lambda_s_opt
: The optimal tuning parameter of the smoothness penalty.
comb_list
: The combinations of G
,lambda_s
and lambda_l
explored.
CV
: The cross-validation values obtained for each combination of G
,lambda_s
and lambda_l
.
CV_sd
: The standard deviations of the cross-validation values.
zeros
: Fraction of domain over which the estimated cluster means are fused.
ms
: The m-standard deviation rule parameters.
class
: A label for the output type.
References
Centofanti, F., Lepore, A., & Palumbo, B. (2021). Sparse and Smooth Functional Data Clustering. arXiv preprint arXiv:2103.15224.
Ramsay, J., Ramsay, J., & Silverman, B. W. (2005). Functional Data Analysis. Springer Science & Business Media.
See Also
Examples
library(sasfunclust)
train<-simulate_data("Scenario I",n_i=20,var_e = 1,var_b = 0.5^2)
lambda_s_seq=10^seq(-4,-3)
lambda_l_seq=10^seq(-1,0)
G_seq=2
mod_cv<-sasfclust_cv(X=train$X,grid=train$grid,G_seq=G_seq,
lambda_l_seq = lambda_l_seq,lambda_s_seq =lambda_s_seq,maxit = 20,K_fold = 2,q=10)
plot(mod_cv)