Skip to contents

The StatisticEngine R6 class is a framework for performing statistical analysis on data. Data can be added as a character vector with a path to a csv file with variable names as first row and analyses names as first column or a data.frame or matrix object.

Note

Note that the model must be created before prediction and data must have the same number of variables as the model. Also, any pre-processing applied to the model data should be applied to the data before prediction. Note that only numeric values are accepted in data and the data column names are used as variable names and data row names are used as analyses names.

Note that the model must be created before testing and data must have the same number of variables as the model. Also, any pre-processing applied to the model data should be applied to the data before testing. Note that only numeric values are accepted in data and the data column names are used as variable names and data row names are used as analyses names.

Super class

StreamFind::CoreEngine -> StatisticEngine

Active bindings

data

Data object.

model

Statistic model.

quantification

Quantification results.

prediction_results

Prediction results.

classification_results

Classification results.

Methods

Inherited methods


Method new()

Creates an R6 class StatisticEngine. Child of CoreEngine R6 class.

Usage

StatisticEngine$new(
  file = NULL,
  headers = NULL,
  workflow = NULL,
  analyses = NULL
)

Arguments

file

Character of length one with the full path to the sqlite/rds save file of the engine.

headers

A ProjectHeaders S7 class object.

workflow

A Workflow S7 class object.

analyses

A StatisticAnalyses S7 class object or a character vector with full file path to .csv file with variable names as first row and analyses names as first column or a data.frame or matrix object.


Method get_overview()

Gets an overview data.frame of all the analyses.

Usage

StatisticEngine$get_overview()


Method get_classes()

Gets the class of each analysis.

Usage

StatisticEngine$get_classes()


Method get_concentrations()

Gets the concentration of each analysis.

Usage

StatisticEngine$get_concentrations()


Method get_number_variables()

Gets the number of variables.

Usage

StatisticEngine$get_number_variables()


Method get_model_contributions()

Gets the model contributions.

Usage

StatisticEngine$get_model_contributions(pcs = NULL)

Arguments

pcs

Integer vector with the principle components.


Method add_analyses()

Adds analyses. Note that when adding new analyses, any existing results are removed. Note that the data must have the same number and names of variables (i.e., columns) as the model.

Usage

StatisticEngine$add_analyses(analyses = NULL)

Arguments

analyses

A character vector with full file path to .csv file with variable names as first row and analyses names as first column or a data.frame or matrix object.

Returns

Invisible.


Method add_classes()

Adds classes to the analyses.

Usage

StatisticEngine$add_classes(classes)

Arguments

classes

A character vector with the classes.


Method add_concentrations()

Adds concentrations to the analyses.

Usage

StatisticEngine$add_concentrations(concentrations = NA_real_)

Arguments

concentrations

A numeric vector with the concentrations.


Method remove_analyses()

Removes analyses.

Usage

StatisticEngine$remove_analyses(analyses = NULL)

Arguments

analyses

A character vector with the names or numeric vector with indices of the analyses to remove.

Returns

Invisible.


Method predict()

Predicts the data using the model.

Usage

StatisticEngine$predict(data = NULL)

Arguments

data

Data.frame, data-table or matrix with data.


Method test()

Tests the model using the data.

Usage

StatisticEngine$test(data = NULL)

Arguments

data

Data.frame, data-table or matrix with data.


Method plot_data()

Plots the data.

Usage

StatisticEngine$plot_data(
  analyses = NULL,
  features = NULL,
  transpose = FALSE,
  interactive = TRUE,
  xLab = NULL,
  yLab = NULL,
  title = NULL
)

Arguments

analyses

A numeric/character vector with the number/name of the analyses.

features

A numeric vector with the features (columns of data matrix) to plot.

transpose

Logical, if TRUE the data is transposed (i.e., column names are used as legend).

interactive

Logical (length 1). When TRUE, the data is plotted interactively using plotly.

xLab

A string with the title for the x axis.

yLab

A string with the title for the y axis.

title

A string with the title.


Method plot_explained_variance()

Plots the model explained cumulative variance.

Usage

StatisticEngine$plot_explained_variance(
  interactive = TRUE,
  xLab = NULL,
  yLab = NULL,
  title = NULL
)

Arguments

interactive

Logical (length 1). When TRUE, the data is plotted interactively using plotly.

xLab

A string with the title for the x axis.

yLab

A string with the title for the y axis.

title

A string with the title.


Method plot_scores()

Plots scores of the model.

Usage

StatisticEngine$plot_scores(
  analyses = NULL,
  interactive = TRUE,
  pcs = 1:2,
  title = NULL,
  colorGroups = NULL,
  showText = TRUE,
  showLegend = TRUE
)

Arguments

analyses

A numeric/character vector with the number/name of the analyses.

interactive

Logical (length 1). When TRUE, the data is plotted interactively using plotly.

pcs

A numeric vector (length 2) with the principle components to plot.

title

A string with the title.

colorGroups

A factor character vector with the color groups for the scores.

showText

Logical (length 1), set to TRUE to show the text annotations.

showLegend

Logical (length 1). Set to TRUE to show legend.


Method plot_residuals()

Plots residuals of the model.

Usage

StatisticEngine$plot_residuals(
  analyses = NULL,
  interactive = TRUE,
  xLab = NULL,
  yLab = NULL,
  title = NULL
)

Arguments

analyses

A numeric/character vector with the number/name of the analyses.

interactive

Logical (length 1). When TRUE, the data is plotted interactively using plotly.

xLab

A string with the title for the x axis.

yLab

A string with the title for the y axis.

title

A string with the title.


Method plot_loadings()

Plots model loadings.

Usage

StatisticEngine$plot_loadings(
  interactive = TRUE,
  pcs = 1:2,
  colorKey = NULL,
  title = NULL,
  showText = TRUE,
  showLegend = TRUE
)

Arguments

interactive

Logical (length 1). When TRUE, the data is plotted interactively using plotly.

pcs

A vector with the principle components to plot.

colorKey

A character vector with the color key for the loading variables.

title

A string with the title.

showText

Logical (length 1), set to TRUE to show the text annotations.

showLegend

Logical (length 1). Set to TRUE to show legend.


Method plot_resolved_spectra()

Plots model resolved spectra.

Usage

StatisticEngine$plot_resolved_spectra(
  interactive = TRUE,
  pcs = NULL,
  original = TRUE,
  title = NULL,
  showText = TRUE,
  showLegend = TRUE
)

Arguments

interactive

Logical (length 1). When TRUE, the data is plotted interactively using plotly.

pcs

Integer vectors with the principle component to use for categorization.

original

Logical, if TRUE the original data is plotted.

title

A string with the title.

showText

Logical (length 1), set to TRUE to show the text annotations.

showLegend

Logical (length 1). Set to TRUE to show legend.


Method plot_contributions()

Plots model contributions.

Usage

StatisticEngine$plot_contributions(
  interactive = TRUE,
  pcs = NULL,
  title = NULL,
  showText = TRUE,
  showLegend = TRUE
)

Arguments

interactive

Logical (length 1). When TRUE, the data is plotted interactively using plotly.

pcs

Integer vectors with the principle component to use for categorization.

title

A string with the title.

showText

Logical (length 1), set to TRUE to show the text annotations.

showLegend

Logical (length 1). Set to TRUE to show legend.


Method plot_residual_distance()

Plots the residual distance of the model.

Usage

StatisticEngine$plot_residual_distance(...)

Arguments

...

Additional arguments passed to the plotting function.


Method clone()

The objects of this class are cloneable with this method.

Usage

StatisticEngine$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.