The object builds the ALASCA model and contains the data

Public fields

df

Data table/frame. The data to analyze

formula

An AlascaForula object

wide

Boolean. Whether the provided data is in wide format

scale_function

How to scale the data. Options are NULL, custom function, or "sdall", "sdref", "sdt1", "sdreft1"

ignore_missing

If TRUE, ignore missing predictive values

ignore_missing_covars

If TRUE, ignore missing covariate values

version

Version number

update_date

Date of latest update

separate_effects

If TRUE, try to separate the effects

equal_baseline

If TRUE, remove interaction between baselines

effect_list

List. Contains info related to the effects

n_validation_folds

Integer. If using jack-knife validation, exclude 1/n_validation_folds of the participants at each iteration

n_validation_runs

Integer. Number of iterations to use for validation

validation_quantile_method

Integer between 1 and 9. See stats::quantile() for details

save_validation_ids

If TRUE, save the participants in each validation iteration to a csv file

optimize_score

If TRUE, test all combinations of signs for the most important loadings, and choose the combination being the best fit

validate

If TRUE, validate the model

validate_regression

If TRUE, validate get marginal means

validation

Boolean. Synonym to validate

validation_method

String. Defines the validation method; "bootstrap" (default) or "jack-knife"

validation_ids

A data frame where each row contains the ids for one validation iteration

validation_assign_new_ids

Logical. Assign new IDs during validation. Must be TRUE for reduce_dimensions to work

limitsCI

Lower and upper quantile to use for validation

compress_validation

Integer between 0 and 100. See fst::write_fst() for details

reduce_dimensions

Boolean. Use PCA to reduce data dimensions prior to analysis

pca_function

String or custom function. Which pca function to use for dimension reduction, either "prcomp" or "irlba" or "princomp" or custom function

save_to_disk

Write model data to disk to reduce memory usage

db_method

String. Use a "duckdb" or a "SQLite" database for validation data

filename

Filename for the saved model

filepath

Where to save the model. Defaults to ALASCA/<timestamp>

save

Save model data and plots

method

String. Can be "LM" or "LMM"

max_PC

Integer. The maximal number of principal components to keep for further analysis

use_Rfast

Boolean. If TRUE (default), use Rfast, else use lm or lme4

p_adjust_method

String. See stats::p.adjust()

participant_column

String. The column used for IDs. If not provided, it will guess based on random effect or ID

stratification_column

String. Name of the column to use for stratification during validation

explanatory_limit

Only validate components explaining more than explanatory_limit of the variance

init_time

The time when the object is initialized

log_to

String deciding logging target: "all" (default), "file", "console", "none"

log_level

String. What level of log messages to print; "DEBUG", "INFO", "WARN", "ERROR"

do_debug

Boolean. Log more details

finished

Boolean. Indicates whether the model has been successfully initiated

ALASCA

List. Contains all model outputs: score, loading, explained and significant_PCs

Active bindings

get_plot_group

Name of the grouping factor (used for plotting)

effect_terms

List of the terms in the effect matrices

Methods


Method remove_embedded_data()

Usage

AlascaModel$remove_embedded_data()


Method get_default_scaling_function()

Usage

AlascaModel$get_default_scaling_function()


Method get_scaling_function()

Usage

AlascaModel$get_scaling_function()


Method get_pca_function()

Usage

AlascaModel$get_pca_function()


Method build_model()

Usage

AlascaModel$build_model()


Method run_regression()

Usage

AlascaModel$run_regression()


Method get_regression_coefficients()

Usage

AlascaModel$get_regression_coefficients()


Method remove_covars()

Usage

AlascaModel$remove_covars()


Method get_effect_matrix()

Usage

AlascaModel$get_effect_matrix()


Method do_pca()

Usage

AlascaModel$do_pca()


Method do_reduce_dimensions()

Usage

AlascaModel$do_reduce_dimensions()


Method clean_pca()

Usage

AlascaModel$clean_pca()


Method clean_alasca()

Usage

AlascaModel$clean_alasca()


Method do_validate()

Usage

AlascaModel$do_validate()


Method get_validation_percentiles()

Usage

AlascaModel$get_validation_percentiles(objectlist)


Method get_validation_percentiles_regression()

Usage

AlascaModel$get_validation_percentiles_regression(objectlist)


Method get_validation_percentiles_covars()

Usage

AlascaModel$get_validation_percentiles_covars(objectlist)


Method get_validation_percentiles_loading()

Usage

AlascaModel$get_validation_percentiles_loading(objectlist)


Method get_validation_scores()

Usage

AlascaModel$get_validation_scores(objectlist = NULL, effect_i = 1)


Method get_validation_loadings()

Usage

AlascaModel$get_validation_loadings(objectlist = NULL, effect_i = 1)


Method get_validation_percentiles_score()

Usage

AlascaModel$get_validation_percentiles_score(objectlist)


Method get_regression_predictions()

Usage

AlascaModel$get_regression_predictions()


Method get_validation_ids()

Usage

AlascaModel$get_validation_ids()


Method prepare_validation_run()

Usage

AlascaModel$prepare_validation_run(runN)


Method get_bootstrap_data()

Usage

AlascaModel$get_bootstrap_data(df_raw, participants_in_bootstrap, modmat)


Method new()

Usage

AlascaModel$new(df, formula, effects, ...)


Method finalize()

Usage

AlascaModel$finalize()


Method update()

Update the current model (used for validation)

Usage

AlascaModel$update()


Method log()

Function for logging messages using the log4r package

Usage

AlascaModel$log(message, level = "INFO")

Arguments

message

The message to log

level

Level of the message; DEBUG, INFO, WARN, ERROR, FATAL


Method plot()

Main function for plots

Usage

AlascaModel$plot(effect = 1, component = 1, ...)

Arguments

effect

Integer or vector. Which(s) effect(s) to plot

component

Integer or vector. Which(s) component(s) to plot


Method get_residuals()

Resample participants for validation

Usage

AlascaModel$get_residuals(variable = NULL)


Method set_effect_terms()

Usage

AlascaModel$set_effect_terms()


Method set_design_matrices()

Usage

AlascaModel$set_design_matrices()


Method flip()

Switch the sign of scores and loadings

Usage

AlascaModel$flip(effect_i = 0, component = 0)

Arguments

effect_i

The effect to reflect, 0 or NULL reflects the entire model

component

The component to reflect, 0 or NULL reflects the entire model


Method get_ref()

Returns the reference level of a given column

Usage

AlascaModel$get_ref(columns)

Arguments

columns

A column containing factors

Returns

The reference level


Method get_levels()

Returns all the levels of a given column

Usage

AlascaModel$get_levels(column, reduced = TRUE)

Arguments

column

A column containing factors

reduced

Boolean. If TRUE, returns the PCs instead of actual variables if dimensions are reduced with PCA

Returns

A vector with factor levels


Method get_PCs()

Returns the most interesting principal components (i.e., components explaining more than a given limit of variance: explanatory_limit)

Usage

AlascaModel$get_PCs(x)

Arguments

x

Index corresponding to the effect of interest

Returns

A vector with principal components


Method get_predictions()

Usage

AlascaModel$get_predictions()


Method get_scores()

Return scores

Usage

AlascaModel$get_scores(effect_i = 1, component = 1)

Arguments

effect_i

The effect to reflect, 0 or NULL reflects the entire model

component

The component to reflect, 0 or NULL reflects the entire model


Method get_loadings()

Return loadings

Usage

AlascaModel$get_loadings(effect_i = 1, component = 1, n_limit = 0)

Arguments

effect_i

The effect to reflect, 0 or NULL reflects the entire model

component

The component to reflect, 0 or NULL reflects the entire model

n_limit

Return only two times this number of loadings (the n_limit highest and lowest loadings). Use 0 to return all (default)


Method get_covars()

Usage

AlascaModel$get_covars(n_limit = 0)

Arguments

n_limit

Return only two times this number of coefficients (the n_limit highest and lowest coefficients). Use 0 to return all (default)


Method print_version()

Print ALASCA version

Usage

AlascaModel$print_version()

Returns

String with version number and date of latest update


Method save_validation()

Write scores, loadings, covars and predictions from validation run to database and remove data from memory

Usage

AlascaModel$save_validation(ii)

Arguments

ii

Number of the validation run


Method save_to_csv()

Save scores, loading, covars, and predictions to csv files

Usage

AlascaModel$save_to_csv()


Method save_model()

Save model to RDS and scores, loading, covars, and predictions to csv files

Usage

AlascaModel$save_model()


Method rotate_matrix_optimize_score()

Rotate model loadings and scores with procrustes. This function checks all combinations of signs to minimize variation

Usage

AlascaModel$rotate_matrix_optimize_score(target)

Arguments

target

Rotate model (self) with this as target


Method rotate_matrix()

Rotate model loadings and scores with procrustes

Usage

AlascaModel$rotate_matrix(target)

Arguments

target

Rotate model (self) with this as target


Method clone()

The objects of this class are cloneable with this method.

Usage

AlascaModel$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.