Skip to contents

Performs a grid search to find optimal parameters for different analysis methods. Supports Biclustering, LCA (Latent Class Analysis), and LRA (Latent Rank Analysis).

Usage

GridSearch(
  obj,
  max_ncls = 10,
  max_nfld = 10,
  fun = "Biclustering",
  index = "BIC",
  verbose = FALSE,
  skip_empty = TRUE,
  ...
)

Arguments

obj

Input data matrix or object to be analyzed

max_ncls

Maximum number of classes/clusters to test (default: 10)

max_nfld

Maximum number of fields to test for Biclustering (default: 10)

fun

Function name to use for analysis. Options: "Biclustering", "LCA", "LRA" (default: "Biclustering")

index

Fit index to optimize from TestFitIndices returned by each function. Valid options: "BIC" (default), "AIC", "CAIC", "model_log_like", "model_Chi_sq", "RMSEA", "NFI", "RFI", "IFI", "TLI", "CFI". Aliases are also accepted: "loglik", "log_lik", "LogLik", "LL" (all map to "model_log_like"), "Chi_sq", "chi_sq" (map to "model_Chi_sq"). Four indices are taken from the top level of the fit instead: "elbo" and "log_lik_marginal" (maximised), "ICL" and "BIC_elbo" (minimised). "BIC_elbo" is the BIC on the observed-data log-likelihood (-2 elbo + k log N); the default "BIC" is built on the expected complete-data log-likelihood against the benchmark model and behaves differently when classes are added (see the LCA entry in the 2.3.0 news).

verbose

Logical; if TRUE, displays detailed progress messages during grid search. Default is FALSE.

skip_empty

Logical; if TRUE (default), a setting whose fit leaves a class, rank or field with no member (a zero in LCD, LRD or LFD) is recorded in the index table but is not eligible as the optimum. Such a fit has fewer effective classes than requested, usually because the EM produced duplicate reference profiles, so its fit index describes a smaller model. Set to FALSE to choose among all converged settings.

...

Additional arguments passed to the analysis function, for example mixing = "estimate" for LCA and LRA

Value

A list containing: For Biclustering:

index_matrix

Matrix of fit indices for each ncls/nfld combination

optimal_ncls

Optimal number of classes/clusters

optimal_nfld

Optimal number of fields

optimal_result

Analysis result using optimal parameters

failed_settings

List of parameter combinations that failed to converge

empty_settings

List of parameter combinations whose fit left a class, rank or field empty (see skip_empty)

empty_matrix

Logical matrix marking those cells

bound_settings

List of parameter combinations whose ICL_exact is a lower bound (the order probability of some field fell below the Monte Carlo resolution; see Biclustering). They are reported once, and the per-fit warning is not repeated.

bound_matrix

Logical matrix marking those cells

index

Name of the fit index searched

fun

Name of the analysis function

For LCA/LRA:

index_vec

Vector of fit indices for each ncls

optimal_ncls

Optimal number of classes/clusters

optimal_result

Analysis result using optimal parameters

failed_settings

List of parameter combinations that failed to converge

empty_settings

List of parameter combinations whose fit left a class or rank empty (see skip_empty)

empty_vec

Logical vector marking those settings

bound_settings

As above, for ICL_exact

bound_vec

Logical vector marking those settings

index

Name of the fit index searched

fun

Name of the analysis function

plot() on the returned object draws the fit index against the number of classes (one line per nfld for Biclustering, or a surface with style = "persp"); see plot.exametrika.

Examples

if (FALSE) { # \dontrun{
# Grid search for Biclustering
result <- GridSearch(J35S515, max_ncls = 5, max_nfld = 5)

# Grid search for LCA
result <- GridSearch(J35S515, max_ncls = 8, fun = "LCA")

# Fit index against the number of classes
plot(result)

# Arguments for the analysis function pass through: estimate the class
# weights instead of fixing them at 1/C (see ?LCA), and select on the BIC
# of the observed-data log-likelihood
result <- GridSearch(J35S515,
  max_ncls = 8, fun = "LCA", mixing = "estimate",
  index = "BIC_elbo"
)
} # }