| dqc {Qtools} | R Documentation | 
Directional Quantile Classification
Description
This function is used to classify multivariate observations by means of directional quantiles.
Usage
dqc(formula, data, df.test, subset, weights, na.action, control = list(),
	fit = TRUE)
dqc.fit(x, z, y, control)
Arguments
formula | 
 an object of class   | 
data | 
 an optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables for classification (training). If not found in data, the variables are taken from environment(formula), typically the environment from which   | 
df.test | 
 a required data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables for prediction.  | 
subset | 
 an optional vector specifying a subset of observations to be used in the fitting process.  | 
weights | 
 an optional vector of weights to be used in the fitting process.  | 
na.action | 
 a function which indicates what should happen when the data contain   | 
control | 
 list of control parameters of the fitting process. See   | 
fit | 
 logical flag. If   | 
x | 
 design matrix of dimension   | 
z | 
 design matrix of dimension   | 
y | 
 vector of labels of length   | 
Details
Directional quantile classification is described in the article by Viroli et al (2020).
Value
a list of class dqc containing the following components
call | 
 the matched call.  | 
ans | 
 a data frame with predictions.  | 
nx | 
 number of observations in the training dataset.  | 
nz | 
 number of observations in the prediction dataset.  | 
p | 
 number of variables.  | 
control | 
 control parameters used for fitting.  | 
Author(s)
Marco Geraci with contributions from Cinzia Viroli
References
Viroli C, Farcomeni A, Geraci M (2020). Directional quantile-based classifiers (in preparation).
See Also
Examples
## Not run: 
# Iris data
data(iris)
# Create training and prediction datasets
n <- nrow(iris)
ng <- length(unique(iris$Species))
df1 <- iris[c(1:40, 51:90, 101:140),]
df2 <- iris[c(41:50, 91:100, 141:150),]
# Classify
ctrl <- dqcControl(nt = 10, ndir = 5000, seed = 123)
fit <- dqc(Species ~ Sepal.Length + Petal.Length,
	data = df1, df.test = df2, control = ctrl)
# Data frame with predictions
fit$ans
# Confusion matrix
print(cm <- xtabs( ~ fit$ans$groups + df2$Species))
# Misclassification rate
1-sum(diag(cm))/nrow(df2)
## End(Not run)