AlascaModel | R Documentation |
The object builds the ALASCA model and contains the data
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
get_plot_group
Name of the grouping factor (used for plotting)
effect_terms
List of the terms in the effect matrices
remove_embedded_data()
AlascaModel$remove_embedded_data()
get_default_scaling_function()
AlascaModel$get_default_scaling_function()
get_scaling_function()
AlascaModel$get_scaling_function()
get_pca_function()
AlascaModel$get_pca_function()
build_model()
AlascaModel$build_model()
run_regression()
AlascaModel$run_regression()
get_regression_coefficients()
AlascaModel$get_regression_coefficients()
remove_covars()
AlascaModel$remove_covars()
get_effect_matrix()
AlascaModel$get_effect_matrix()
do_pca()
AlascaModel$do_pca()
do_reduce_dimensions()
AlascaModel$do_reduce_dimensions()
clean_pca()
AlascaModel$clean_pca()
clean_alasca()
AlascaModel$clean_alasca()
do_validate()
AlascaModel$do_validate()
get_validation_percentiles()
AlascaModel$get_validation_percentiles(objectlist)
get_validation_percentiles_regression()
AlascaModel$get_validation_percentiles_regression(objectlist)
get_validation_percentiles_covars()
AlascaModel$get_validation_percentiles_covars(objectlist)
get_validation_percentiles_loading()
AlascaModel$get_validation_percentiles_loading(objectlist)
get_validation_scores()
AlascaModel$get_validation_scores(objectlist = NULL, effect_i = 1)
get_validation_loadings()
AlascaModel$get_validation_loadings(objectlist = NULL, effect_i = 1)
get_validation_percentiles_score()
AlascaModel$get_validation_percentiles_score(objectlist)
get_regression_predictions()
AlascaModel$get_regression_predictions()
get_validation_ids()
AlascaModel$get_validation_ids()
prepare_validation_run()
AlascaModel$prepare_validation_run(runN)
get_bootstrap_data()
AlascaModel$get_bootstrap_data(df_raw, participants_in_bootstrap, modmat)
new()
AlascaModel$new(df, formula, effects, ...)
finalize()
AlascaModel$finalize()
update()
Update the current model (used for validation)
AlascaModel$update()
log()
Function for logging messages using the log4r package
AlascaModel$log(message, level = "INFO")
message
The message to log
level
Level of the message; DEBUG, INFO, WARN, ERROR, FATAL
plot()
Main function for plots
AlascaModel$plot(effect = 1, component = 1, ...)
effect
Integer or vector. Which(s) effect(s) to plot
component
Integer or vector. Which(s) component(s) to plot
get_residuals()
Resample participants for validation
AlascaModel$get_residuals(variable = NULL)
set_effect_terms()
AlascaModel$set_effect_terms()
set_design_matrices()
AlascaModel$set_design_matrices()
flip()
Switch the sign of scores and loadings
AlascaModel$flip(effect_i = 0, component = 0)
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
get_ref()
Returns the reference level of a given column
AlascaModel$get_ref(columns)
columns
A column containing factors
The reference level
get_levels()
Returns all the levels of a given column
AlascaModel$get_levels(column, reduced = TRUE)
column
A column containing factors
reduced
Boolean. If TRUE
, returns the PCs instead of actual variables if dimensions are reduced with PCA
A vector with factor levels
get_PCs()
Returns the most interesting principal components (i.e., components explaining more than a given limit of variance: explanatory_limit
)
AlascaModel$get_PCs(x)
x
Index corresponding to the effect of interest
A vector with principal components
get_predictions()
AlascaModel$get_predictions()
get_scores()
Return scores
AlascaModel$get_scores(effect_i = 1, component = 1)
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
get_loadings()
Return loadings
AlascaModel$get_loadings(effect_i = 1, component = 1, n_limit = 0)
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)
get_covars()
AlascaModel$get_covars(n_limit = 0)
n_limit
Return only two times this number of coefficients (the n_limit
highest and lowest coefficients). Use 0
to return all (default)
print_version()
Print ALASCA version
AlascaModel$print_version()
String with version number and date of latest update
save_validation()
Write scores, loadings, covars and predictions from validation run to database and remove data from memory
AlascaModel$save_validation(ii)
ii
Number of the validation run
save_to_csv()
Save scores, loading, covars, and predictions to csv files
AlascaModel$save_to_csv()
save_model()
Save model to RDS and scores, loading, covars, and predictions to csv files
AlascaModel$save_model()
rotate_matrix_optimize_score()
Rotate model loadings and scores with procrustes. This function checks all combinations of signs to minimize variation
AlascaModel$rotate_matrix_optimize_score(target)
target
Rotate model (self
) with this as target
rotate_matrix()
Rotate model loadings and scores with procrustes
AlascaModel$rotate_matrix(target)
target
Rotate model (self
) with this as target
clone()
The objects of this class are cloneable with this method.
AlascaModel$clone(deep = FALSE)
deep
Whether to make a deep clone.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.