lpda {lpda} | R Documentation |
Computing discriminating hyperplane for two groups
Description
This function computes a discriminating hyperplane for two groups with original data (calling lpda.fit) or with principal components (calling lpda.pca)
Usage
lpda(data, group, scale = FALSE, pca = FALSE, PC = 2, Variability = NULL,
f1 = NULL, f2 = NULL)
Arguments
data |
Matrix containing data. Individuals in rows and variables in columns |
group |
Vector with the variable group |
scale |
Logical indicating if data is standarised. When pca=TRUE data is always scaled. |
pca |
Logical indicating if Principal Components Analysis is required |
PC |
Number of Principal Components (PC) for PCA. By default it is 2. When the number of PC is not decided, it can be determined choosing the desired proportion of explained variability (Variability parameter). |
Variability |
Parameter for Principal Components (PC) selection. This is the minimum desired proportion of variability explained for the PC of the variables. The analysis is always done with a minimum of 2 PCs. If it is NULL the PCA will be computed with PC parameter. |
f1 |
Vector with weights for individuals of the first group. If NULL they are equally weighted. |
f2 |
Vector with weights for individuals of the second group. If NULL they are equally weighted. |
Value
lpda
returns an object of class "lpda
".
The functionspredict
and plot
can be used to obtain the predicted classes and a plot in two dimensions with the distances to the computed hyperplane for the two classes.
coef |
Hyperplane coefficients |
data |
Input data matrix when pca = FALSE and scores when pca = TRUE |
group |
Input group vector |
scale |
Input scale argument |
pca |
Input pca argument |
loadings |
Principal Components loadings. Showed when pca = TRUE |
scores |
Principal Components scores. Showed when pca = TRUE |
var.exp |
A matrix containing the explained variance for each component and the cumulative variance. Showed when pca = TRUE |
PCs |
Number of Principal Components in the analysis. Showed when pca = TRUE |
Author(s)
Maria Jose Nueda, mj.nueda@ua.es
References
Nueda MJ, GandÃa C, Molina MD (2022) LPDA: A new classification method based on linear programming. PLoS ONE 17(7): e0270403. <https://doi.org/10.1371/journal.pone.0270403>
See Also
Examples
######### palmdates example in lpda package:
data(palmdates)
group = as.factor( c(rep("Spanish",11),rep("Foreign",10)) )
# with concentration data:
model = lpda(data = palmdates$conc, group = group )
pred = predict(model)
table(pred$fitted, group)
plot(model, main = "Palmdates example")
model.pca = lpda(data = palmdates$conc, group = group, pca=TRUE, PC = 2)
plot(model.pca, PCscores = TRUE, main = "Palmdates example")
# with spectra data
model.pca = lpda(data = palmdates$spectra, group = group, pca=TRUE, Variability = 0.9)
model.pca$PCs # 4 PCs to explain 90% of the variability
plot(model.pca, PCscores = TRUE, main = "Spectra palmdates")