knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(dataAnalysisMisc)

Load data

meta <- read.csv(paste(system.file("extdata", package="dataAnalysisMisc"), "/meta.csv",sep=""), row.names=1)
data <- read.csv(paste(system.file("extdata", package="dataAnalysisMisc"), "/data_m.csv", sep=""), row.names=1)

require(ggplot2)
ggplot(meta, aes(x=CONT)) + geom_histogram()
ggplot(meta, aes(x=BIN)) + geom_histogram()

Logistic regression: binary classification

Create instance

# Please assure manually that order of cols of data corresponds
# to order of rows in meta

obj <- new("fitModel", data, meta, var="BIN", type="lr")

test differences

Test influence of grouping covariate (will be the predicted variable) on the dependent variables (features)

Likelihood ratio test p-value (per model) to select features.

obj <- testSign(obj, pCut=0.05, pAdj="none")

### with covariates
objC <- testSign(obj, pCut=0.05, pAdj="none", 
        frm0=as.formula(VAL~CONT),
        frm=as.formula(VAL~CONT+BIN))

crossvalidation

## non adjusted
obj <- cv(obj)

##adjusted
objC <- cv(obj, frm="~CONT+BIN")

model fitting + plot

obj <- fitM(obj, interval="prediction") 
obj <- fitM(obj, interval="prediction", type="response") 
plotModel(obj)
obj@model

### log reg # default: prediciton interval
rocDetail(obj@pred$fit, obj@meta$BIN)
rocDetail(obj@pred$fit, obj@meta$BIN, obj@model)

Linear regression

Create instance

# Please assure manually that order of cols of data corresponds
# to order of rows in meta
obj <- new("fitModel", data, meta, var="CONT", type="lm")

test differences

Test influence of grouping covariate (will be the predicted variable) on the dependent variables (features)

Likelihood ratio test p-value (per model) to select features.

obj <- testSign(obj, pCut=0.05, pAdj="none")

### with covariates
objC <- testSign(obj, pCut=0.05, pAdj="none", 
        frm0=as.formula(VAL~CONT),
        frm=as.formula(VAL~CONT+BIN))

crossvalidation

## non adjusted
obj <- cv(obj)

##adjusted
objC <- cv(obj, frm="~CONT+BIN")

model fitting + plot

obj <- fitM(obj, interval="prediction") 
obj <- fitM(obj, interval="prediction", type="response") 
plotModel(obj)

objC <- fitM(obj, interval="confidence") 
objC <- fitM(obj, interval="confidence", type="response") 
plotModel(objC)


mknoll/dataAnalysisMisc documentation built on Feb. 4, 2024, 8:16 a.m.