predict.osc: Predict Method for Class 'osc'

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/mt_osc.R

Description

Pre-processing of new data by osc.

Usage

1
2
## S3 method for class 'osc'
predict(object, newdata,...)

Arguments

object

Object of class osc.

newdata

A matrix or data frame of cases to be corrected by OSC.

...

Arguments based from or to other methods.

Details

This function is a method for the generic function predict() for class osc. If newdata is omitted, the corrected data set used in model of osc will be returned.

Value

A list containing the following components:

x

A matrix of OSC corrected data set.

Q2

The fraction of variation in X after OSC correction for the new data.

Author(s)

Wanchang Lin

See Also

osc, osc_wold, osc_sjoblom, osc_wise

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
data(abr1)
cl   <- factor(abr1$fact$class)
dat  <- abr1$pos

## divide data as training and test data
idx <- sample(1:nrow(dat), round((2/3)*nrow(dat)), replace=FALSE) 

## construct train and test data 
train.dat  <- dat[idx,]
train.t    <- cl[idx]
test.dat   <- dat[-idx,]        
test.t     <- cl[-idx] 

## build OSC model based on the training data
res <- osc(train.dat, train.t, method="wold",osc.ncomp=2, pls.ncomp=4)
names(res)
res
summary(res)

## pre-process test data by OSC
test <- predict(res,test.dat)
test.dat.1 <- test$x

mt documentation built on Feb. 2, 2022, 1:07 a.m.