predict.rqda: Restricted Quadratic Discriminant Analysis. Multivariate...

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

Description

Classify multivariate observations with quadratic classification rules built with additional information in conjunction with rqda.

Usage

1
2
3
## S3 method for class 'rqda'
predict(object, newdata, prior = object$prior,
        gamma = object$gamma, grouping = NULL, ...)

Arguments

object

An object of class 'rqda'.

newdata

A data frame of cases to be classified, containing the variables used on creating object. A vector will be interpreted as a row vector.

prior

The prior probabilities of class membership. If unspecified, object$prior probabilities are used. If present, the probabilities must be specified in the order of the factor levels.

gamma

A vector of values specifying which rules to take among the ones in object. If unspecified, all rules built with object$gamma will be used. If present, gamma must be contained in object$gamma.

grouping

A numeric vector or factor with numeric levels specifying the class for each observation. If present, true error rate will be estimated from newdata.

...

Arguments based from or to other methods.

Details

This function is a method for the generic function predict() for class 'rqda'.

Value

A list with components

call

The (matched) function call.

class

Matriarchx with the classification for each rule (in columns).

prior

The prior probabilities of the classes used.

posterior

Array with the posterior probabilities of the classes for each rule.

error.rate

True error rate estimation (when grouping specified) for each rule, based on newdata.

Note

If there are missing values in newdata, corresponding observations will not be classified.

If there are missing values in grouping, corresponding observations will not be considered on calculating the true error rate.

Author(s)

David Conde

References

Conde, D., Fernandez, M. A., Rueda, C., and Salvador, B. (2012). Classification of samples into two or more ordered populations with application to a cancer trial. Statistics in Medicine, 31, 3773-3786.

Conde, D., Fernandez, M. A., Salvador, B., and Rueda, C. (2015). dawai: An R Package for Discriminant Analysis with Additional Information. Journal of Statistical Software, 66(10), 1-19. URL http://www.jstatsoft.org/v66/i10/.

See Also

rqda, err.est.rqda, rlda, predict.rlda, err.est.rlda

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(Vehicle2)
levels(Vehicle2$Class)
## "bus" "opel" "saab" "van"

data <- Vehicle2[, 1:4]
grouping = Vehicle2$Class
levels(grouping) <- c(4, 2, 1, 3)
## classes ordered by increasing size
## 
## according to variable definitions, we can consider 
## the following restrictions on the means vectors:
## mu11 >= mu21 >= mu31 >= mu41
## mu12 >= mu22 >= mu32 >= mu42
## mu13 >= mu23 >= mu33 >= mu43
## 
## we can specify these restrictions by restext = "s>1,2,3"

set.seed(7964)
values <- runif(dim(data)[1])
trainsubset <- values < 0.2
testsubset <- values >= 0.2
obj <- rqda(data, grouping, subset = trainsubset,
            gamma = (1:5)/5, restext = "s>1,2,3")
pred <- predict(obj, newdata = data[testsubset,], 
                grouping = grouping[testsubset])
pred$error.rate
## we can see that the test error rate of the restricted
## rules decrease with gamma:
##                      gamma=0.2 gamma=0.4 gamma=0.6 gamma=0.8  gamma=1
## True error rate (%):  40.14815  39.85185  39.85185  39.11111 39.11111

dawai documentation built on May 2, 2019, 6:47 a.m.