View source: R/Tuning_CKNNRLD.R
| CKNNRLD.tune | R Documentation |
Automatically selects the best number of clusters (C) using internal validation criteria, then tunes the CKNNRLD model within each cluster via cross-validation.
CKNNRLD.tune(
y,
x,
nfolds = 10,
folds = NULL,
seed = NULL,
A = 10,
C_range = 2:6,
cluster_method = "kml"
)
y |
Matrix of longitudinal outcomes (subjects x timepoints). |
x |
Matrix of predictor variables (subjects x features). |
nfolds |
Number of folds for cross-validation (default = 10). |
folds |
Optional list of pre-specified fold indices. |
seed |
Random seed for reproducibility. |
A |
Maximum number of neighbors to evaluate (searches from 2 to A, default = 10). |
C_range |
Range of cluster numbers to evaluate (default = 2:6). |
cluster_method |
Clustering method to use. Currently supports "kml" (default). |
A list containing:
best_c |
Optimal number of clusters |
cluster_results |
Tuning results for each cluster (from KNNRLD.tune) |
cluster_sizes |
Size of each cluster |
cluster_assignments |
Cluster labels for each subject |
criteria |
Data frame of quality criteria used for selecting best C |
set.seed(123)
n <- 30
T <- 3
d <- 2
x <- matrix(runif(n * d), nrow = n)
y <- matrix(rnorm(n * T), nrow = n)
tune_result <- CKNNRLD.tune(
y = y,
x = x,
nfolds = 3,
A = 4,
C_range = 2:3
)
print(tune_result$best_c)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.