Skip to contents

The StatisticEngine R6 class is a framework for performing statistical analysis on data.

Note

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. The data is internally converted to StatisticAnalysis objects.

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 classification must be prepared before using the method prepare_classification and data must have the same number of variables as the analyses in the engine.

Note that only the model MCR is valid for quantification and concentrations must be added to analyses.

Super class

StreamFind::CoreEngine -> StatisticEngine

Active bindings

data

Matrix of the data, where rows represent analyses and columns variables.

model

Statistic model.

prediction_results

Prediction results from model.

classification_results

Classification results.

Methods

Inherited methods


Method new()

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

Usage

StatisticEngine$new(
  data = NULL,
  headers = NULL,
  settings = NULL,
  analyses = NULL,
  results = NULL
)

Arguments

data

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

headers

A named list with headers or a ProjectHeaders S3 class object. Each list element must have length one. There is no type restrictions except for name (must be type character length 1), author (must be type character length 1), file (must be type character length 1) and date (must be class POSIXct or class POSIXt length 1). See more information in ?ProjectHeaders.

settings

A named list of ProcessingSettings objects or a single ProcessingSettings object. The list names should match the call name of each ProcessingSettings object. Alternatively, a named list with call name, algorithm and parameters to be transformed and added as ProcessingSettings object.

analyses

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

results

A named list of objects from processing methods.


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_explained_variance()

Gets model explained variance.

Usage

StatisticEngine$get_model_explained_variance()


Method get_model_scores()

Gets model scores.

Usage

StatisticEngine$get_model_scores(analyses = NULL)

Arguments

analyses

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


Method get_model_loadings()

Gets model loadings.

Usage

StatisticEngine$get_model_loadings()


Method get_model_residuals()

Gets model residuals.

Usage

StatisticEngine$get_model_residuals(analyses = NULL)

Arguments

analyses

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


Method get_model_resolved_spectra()

Gets model resolved spectra.

Usage

StatisticEngine$get_model_resolved_spectra(pcs = NULL)

Arguments

pcs

Integer vector with the principle components.


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.

Usage

StatisticEngine$add_analyses(analyses = NULL)

Arguments

analyses

A StatisticAnalysis S3 class object or a list with StatisticAnalysis S3 class objects as elements (see ?StatisticAnalysis for more information).

Returns

Invisible.


Method add_data()

Adds data to the StatisticEngine object.

Usage

StatisticEngine$add_data(data)

Arguments

data

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


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 predict()

Predicts the data using the model.

Usage

StatisticEngine$predict(data = NULL)

Arguments

data

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


Method classify()

Classifies the data using the classification labels of the analysis.

Usage

StatisticEngine$classify(data = NULL)

Arguments

data

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


Method quantify()

Evaluates the model for quantification.

Usage

StatisticEngine$quantify()


Method plot_data()

Plots the raw data in analyses.

Usage

StatisticEngine$plot_data(
  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_model_explained_variance()

Plots the model explained cumulative variance.

Usage

StatisticEngine$plot_model_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_model_scores()

Plots scores of the model.

Usage

StatisticEngine$plot_model_scores(
  analyses = NULL,
  interactive = TRUE,
  pcs = 1:2,
  title = 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.

showText

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

showLegend

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


Method plot_model_residuals()

Plots residuals of the model.

Usage

StatisticEngine$plot_model_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_model_loadings()

Plots model loadings.

Usage

StatisticEngine$plot_model_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_model_resolved_spectra()

Plots model resolved spectra.

Usage

StatisticEngine$plot_model_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_model_contributions()

Plots model contributions.

Usage

StatisticEngine$plot_model_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_predicted_distances()

Plots scores of the model.

Usage

StatisticEngine$plot_predicted_distances(
  pc = NULL,
  interactive = TRUE,
  title = NULL,
  showText = TRUE,
  showLegend = TRUE
)

Arguments

pc

Integer (length 1) with the principle component to use for categorization.

interactive

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

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 processing_methods()

A data.table with available data processing methods.

Usage

StatisticEngine$processing_methods()


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.