logisticRegressionInterface {ClassifyR}R Documentation

An Interface for mnlogit Package's mnlogit Function

Description

logisticRegressionTrainInterface generates a multinomial logistic regression model trained on some training data and logisticRegressionPredictInterface makes class predictions for samples in the test data set.

Usage

  ## S4 method for signature 'matrix'
logisticRegressionTrainInterface(measurements, classes, ...)
  ## S4 method for signature 'DataFrame'
logisticRegressionTrainInterface(measurements, classes, ..., verbose = 3)
  ## S4 method for signature 'MultiAssayExperiment'
logisticRegressionTrainInterface(measurements, targets = names(measurements), ...)
  ## S4 method for signature 'mnlogit,matrix'
logisticRegressionPredictInterface(model, test, ...)
  ## S4 method for signature 'mnlogit,DataFrame'
logisticRegressionPredictInterface(model, test, classes = NULL, verbose = 3)
  ## S4 method for signature 'mnlogit,MultiAssayExperiment'
logisticRegressionPredictInterface(model, test, targets = names(test), ...)  

Arguments

measurements

Either a matrix, DataFrame or MultiAssayExperiment containing the training data. For a matrix, the rows are features, and the columns are samples.

classes

Either a vector of class labels of class factor of the same length as the number of samples in measurements or if the measurements are of class DataFrame a character vector of length 1 containing the column name in measurement is also permitted. Not used if measurements is a MultiAssayExperiment object.

test

An object of the same class as measurements with no samples in common with measurements and the same number of features as it. Also, if a DataFrame, the class column must be absent.

targets

If measurements is a MultiAssayExperiment, the names of the data tables to be used. "clinical" is also a valid value and specifies that integer variables from the clinical data table will be used.

model

A fitted model as returned by logisticRegressionTrainInterface.

...

Variables not used by the matrix nor the MultiAssayExperiment method which are passed into and used by the DataFrame method or optional settings that are passed to mnlogit.

verbose

Default: 3. A number between 0 and 3 for the amount of progress messages to give. This function only prints progress messages if the value is 3.

Details

If measurements is an object of class MultiAssayExperiment, the factor of sample classes must be stored in the DataFrame accessible by the colData function with column name "class".

This wrapper works with individual-specific variables. If more a complex experimental design is utilised, such as a market research data set with both individual-specific and alternative-specific variables, then this wrapper is not suitable to classify it.

Value

For logisticRegressionTrainInterface, a fitted multinomial logistic regression model. For logisticRegressionPredictInterface, a factor vector with class predictions for the samples in the test set.

Author(s)

Dario Strbenac

Examples

  if(require(mnlogit))
  {
    variables <- c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width")
    trainSamples <- c(1:45, 51:95, 101:145)
    testSamples <- c(46:50, 96:100, 146:150)
    
    trained <- logisticRegressionTrainInterface(DataFrame(iris[trainSamples, variables]),
                                                iris[trainSamples, "Species"])
    predicted <- logisticRegressionPredictInterface(trained,
                                         DataFrame(iris[testSamples, variables]))
  }

[Package ClassifyR version 2.0.10 Index]