getnorm: Direct sparse discriminant analysis

Description Usage Arguments Value References Examples

View source: R/getnorm.R

Description

Transform the predictors to achieve normality.

Usage

1
getnorm(x, y, type="pooled")

Arguments

x

an n dimensional vector containing n observations for one predictor.

y

an n-dimensional vector containing the class labels.

type

The type of estimator. Two estimators were proposed in Mai & Zou (2015), the naive estimator and the pooled estimator. The function getnorm() uses the naive estimator if type="naive", and it uses the pooled estimator if type="pooled". The default is "pooled". When the naive estimator is used, it is recommended to label the class with more samples as Class 0.

Value

x.norm

Transformed x.

f0

The transformation computed based on observations from Class 0. Not applicable if type="naive".

f1

The transformation computed based on observations from Class 1. Not applicable if type="naive".

mu.hat

The sample mean for transformed x from Class 1.

transform

The transformation that was actually used to transform x.

References

Mai, Q., Zou, H. and Yuan, M. (2013). A direct approach to sparse discriminant analysis in ultra-high dimensions. Biometrika, 99, 29-42.

Mai, Q. and Zou, H. (2015). Sparse semiparametric discriminant analysis. Journal of Multivariate Analysis, 135, 175-188.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
data(GDS1615)   ##load the prostate data
x<-GDS1615$x
y<-GDS1615$y
x<-exp(x[which(y<3),])
y<-y[which(y<3)]

n<-length(y)
n1<-sum(y==1)
n2<-n-n1
n1.test<-round(n1/2)
n2.test<-round(n2/2)
n.test<-n1.test+n2.test
n.train<-n-n.test
id.test<-c(sample(which(y==1),n1.test),sample(which(y==2),n2.test))

p<-ncol(x)
x.train<-x[-id.test,]
y.train<-y[-id.test]
x.test<-x[id.test,]
y.test<-y[id.test]

 x.norm<-matrix(0,n.train,p)
  x.test.norm<-matrix(0,n.test,p)
  for(i in 1:p){
    obj.norm<-getnorm(x.train[,i],y.train)
    x.norm[,i]<-obj.norm$x.norm
    x.test.norm[,i]<-obj.norm$transform(x.test[,i])
  }
    
  obj<-dsda.all(x.norm,y.train,x.test.norm,y.test)

TULIP documentation built on Jan. 13, 2021, 3:14 p.m.

Related to getnorm in TULIP...