baseGLMnet: Prediction by generalized linear regression models

View source: R/BioMM.R

baseGLMnetR Documentation

Prediction by generalized linear regression models

Description

Prediction by generalized regression models with lasso or elastic net regularization.

Usage

baseGLMnet(
  trainData,
  testData,
  predMode = c("classification", "probability", "regression"),
  paramlist = list(family = "binomial", alpha = 0.5, typeMeasure = "mse", typePred =
    "class")
)

Arguments

trainData

The input training dataset. The first column is named the 'label'.

testData

The input test dataset. The first column is named the 'label'.

predMode

The prediction mode. Available options are c('classification', 'probability', 'regression').

paramlist

A set of model parameters defined in an R list object. The valid option: list(family, alpha, typeMeasure, typePred).

  1. 'family': Response type: 'gaussian','binomial','poisson', 'multinomial','cox','mgaussian'. (Default: 'binomial')

  2. 'alpha': The elastic net mixing parameter, with 0<=alpha<= 1.

  3. 'typeMeasure': error metrics for internal cross-validation. 'mse' uses squared loss; 'deviance' uses actual deviance; 'mae' uses mean absolute error; 'class' gives misclassification error; 'auc' (for two-class logistic regression ONLY) gives area under the ROC curve.

  4. 'typePred': The type of prediction: 'response' and 'class'. (Default: 'class' for binary classification)

Value

The predicted output for the test data.

Author(s)

Junfang Chen

Examples

 
## Load data  
methylfile <- system.file('extdata', 'methylData.rds', package='BioMM')  
methylData <- readRDS(methylfile)  
dataY <- methylData[,1]
## select a subset of genome-wide methylation data at random
methylSub <- data.frame(label=dataY, methylData[,c(2:2001)])  
trainIndex <- sample(nrow(methylSub), 16)
trainData = methylSub[trainIndex,]
testData = methylSub[-trainIndex,]
library(glmnet)
## classification
predY <- baseGLMnet(trainData, testData, 
                    predMode='classification', 
                    paramlist=list(family='binomial', alpha=0.5, 
                                   typeMeasure='mse', typePred='class')) 
testY <- testData[,1]
accuracy <- classifiACC(dataY=testY, predY=predY)
print(accuracy)  

transbioZI/BioMM documentation built on Jan. 12, 2023, 2:18 p.m.