Title: | Consistency in the Analytic Hierarchy Process |
---|---|
Description: | A Swiss Army knife of utility functions for users of the Analytic Hierarchy Process (AHP) which will help you to assess the consistency of a PCM as well as to improve its consistency ratio, to compute the sensitivity of a PCM, create a logical, not a random PCM, from the preferences you provide for the alternatives, and a function that helps evaluate the actual consistency of a PCM based on objective, fair bench marking. The various functions in the toolkit additionally provide the flexibility to users to specify only the upper triangular comparison ratios of the PCM in order to performs its assigned task. |
Authors: | Amarnath Bose [aut, cre] |
Maintainer: | Amarnath Bose <[email protected]> |
License: | GPL-3 |
Version: | 0.2.0 |
Built: | 2025-02-23 04:31:41 UTC |
Source: | https://github.com/amarnathbose/ahptools |
Computes and returns the Consistency Ratio for an input PCM and its boolean status of consistency based on Consistency Ratio
CR(PCM, typePCM = TRUE)
CR(PCM, typePCM = TRUE)
PCM |
A pairwise comparison matrix |
typePCM |
boolean flag indicating if the first argument is a PCM or a vector of upper triangular elements |
A list of 3 elements, a boolean for the 'CR' consistency of the input 'PCM', the 'CR' consistency value and the principal eigenvector
CR.pcm1 <- CR(matrix( c(1,1,7,1,1, 1,1,5,1,1/3, 1/7,1/5,1,1/7,1/8, 1,1,7,1,1, 1,3,8,1,1), nrow=5, byrow=TRUE)) CR.pcm1 CR.pcm1a <- CR(c(1,7,1,1, 5,1,1/3, 1/7,1/8, 1), typePCM=FALSE) CR.pcm1a CR.pcm2 <- CR(matrix( c(1,1/4,1/4,7,1/5, 4,1,1,9,1/4, 4,1,1,8,1/4, 1/7,1/9,1/8,1,1/9, 5,4,4,9,1), nrow=5, byrow=TRUE)) CR.pcm2 CR.pcm2a <- CR(c(1/4,1/4,7,1/5, 1,9,1/4, 8,1/4, 1/9),typePCM=FALSE) CR.pcm2a
CR.pcm1 <- CR(matrix( c(1,1,7,1,1, 1,1,5,1,1/3, 1/7,1/5,1,1/7,1/8, 1,1,7,1,1, 1,3,8,1,1), nrow=5, byrow=TRUE)) CR.pcm1 CR.pcm1a <- CR(c(1,7,1,1, 5,1,1/3, 1/7,1/8, 1), typePCM=FALSE) CR.pcm1a CR.pcm2 <- CR(matrix( c(1,1/4,1/4,7,1/5, 4,1,1,9,1/4, 4,1,1,8,1/4, 1/7,1/9,1/8,1,1/9, 5,4,4,9,1), nrow=5, byrow=TRUE)) CR.pcm2 CR.pcm2a <- CR(c(1/4,1/4,7,1/5, 1,9,1/4, 8,1/4, 1/9),typePCM=FALSE) CR.pcm2a
Creates a logical pairwise comparison matrix for the Analytic Hierarchy Process such as would be created by a rational decision maker based on a relative vector of preferences for the alternatives involved. Choices of the pairwise comparison ratios are from the Fundamental Scale and simulate a reasonable degree of error. The algorithm is modified from a paper by Bose, A [2022], doi:10.1002/mcda.1784
createLogicalPCM(ord, prefVec = rep(NA, ord))
createLogicalPCM(ord, prefVec = rep(NA, ord))
ord |
The desired order of the Pairwise Comparison Matrix |
prefVec |
The preference vector of length as the order of the input matrix |
A Logical Pairwise Comparison Matrix
lPCM <- createLogicalPCM(3,c(1,2,3)); lPCM <- createLogicalPCM(5,c(0.25,0.4,0.1,0.05,0.2));
lPCM <- createLogicalPCM(3,c(1,2,3)); lPCM <- createLogicalPCM(5,c(0.25,0.4,0.1,0.05,0.2));
Create a Pairwise Comparison Matrix of order n from a vector of length n(n-1)/2 independent upper triangular elements
createPCM(vec)
createPCM(vec)
vec |
The preference vector of length as the order of the 'PCM' |
A Pairwise Comparison Matrix corresponding to the upper triangular elements
PCM <- createPCM(c(1,2,0.5,3,0.5,2)); PCM <- createPCM(c(1,.5,2,1/3,4,2,.25,1/3,.5,1,.2,6,2,3,1/3));
PCM <- createPCM(c(1,2,0.5,3,0.5,2)); PCM <- createPCM(c(1,.5,2,1/3,4,2,.25,1/3,.5,1,.2,6,2,3,1/3));
For an input pairwise comparison matrix, PCM that is inconsistent, this function returns a consistent PCM if possible, with the relative preference for its alternatives as close as possible to the original preferences, as in the principal right eigenvector.
improveCR(PCM, typePCM = TRUE)
improveCR(PCM, typePCM = TRUE)
PCM |
A pairwise comparison matrix |
typePCM |
boolean flag indicating if the first argument is a PCM or a vector of upper triangular elements |
A list of 4 elements, suggested PCM, a boolean for the CR consistency of the input PCM, the CR consistency value, a boolean for the CR consistency of the suggested PCM, the CR consistency value of the suggested PCM
CR.suggest2 <- improveCR(matrix( c(1,1/4,1/4,7,1/5, 4,1,1,9,1/4, 4,1,1,8,1/4, 1/7,1/9,1/8,1,1/9, 5,4,4,9,1), nrow=5, byrow=TRUE)) CR.suggest2 CR.suggest2a <- improveCR(c(1/4,1/4,7,1/5, 1,9,1/4, 8,1/4, 1/9), typePCM=FALSE) CR.suggest2a CR.suggest3 <- improveCR(matrix( c(1,7,1,9,8, 1/7,1,1/6,7,9, 1,6,1,9,9, 1/9,1/7,1/9,1,5, 1/8,1/9,1/9,1/5,1), nrow=5, byrow=TRUE)) CR.suggest3
CR.suggest2 <- improveCR(matrix( c(1,1/4,1/4,7,1/5, 4,1,1,9,1/4, 4,1,1,8,1/4, 1/7,1/9,1/8,1,1/9, 5,4,4,9,1), nrow=5, byrow=TRUE)) CR.suggest2 CR.suggest2a <- improveCR(c(1/4,1/4,7,1/5, 1,9,1/4, 8,1/4, 1/9), typePCM=FALSE) CR.suggest2a CR.suggest3 <- improveCR(matrix( c(1,7,1,9,8, 1/7,1,1/6,7,9, 1,6,1,9,9, 1/9,1/7,1/9,1,5, 1/8,1/9,1/9,1/5,1), nrow=5, byrow=TRUE)) CR.suggest3
This function returns the revised consistency classification for a PCM, evaluated by comparison with the threshold of consistency for intentional PCMs in the same preference heterogeneity quartile. The measure for inconsistency is the geometric mean of ratios in comparison with the corresponding benchmark PCM.
revisedConsistency(PCM, typePCM = TRUE)
revisedConsistency(PCM, typePCM = TRUE)
PCM |
A pairwise comparison matrix |
typePCM |
boolean flag indicating if the first argument is a PCM or a vector of upper triangular elements |
A list of four elements, revCons = the revised consistency classification, inconGM = the Geometric Mean measure of inconsistency with the best 'PCM', dQrtl = the preference heterogeneity quartile for the normalized eigenvector, and diff = the preference heterogeneity measure
revCon1 <- revisedConsistency(matrix( c(1,1/4,1/4,7,1/5, 4,1,1,9,1/4, 4,1,1,8,1/4, 1/7,1/9,1/8,1,1/9, 5,4,4,9,1), nrow=5, byrow=TRUE)) revCon1 revCon2 <- revisedConsistency(c(7,1,9,8, 1/6,7,9, 9,9, 5), typePCM=FALSE) revCon2
revCon1 <- revisedConsistency(matrix( c(1,1/4,1/4,7,1/5, 4,1,1,9,1/4, 4,1,1,8,1/4, 1/7,1/9,1/8,1,1/9, 5,4,4,9,1), nrow=5, byrow=TRUE)) revCon1 revCon2 <- revisedConsistency(c(7,1,9,8, 1/6,7,9, 9,9, 5), typePCM=FALSE) revCon2
This function returns a sensitivity measure for an input pairwise comparison matrix, PCM. Sensitivity is measured by Monte Carlo simulation of 500 PCMs which are perturbations of the input PCM. The perturbation algorithm makes a random choice from one of the 5 closest items in the Fundamental Scale {1/9, 1/8, ..... 1/2, 1, 2, ..... 8, 9} for each element in the PCM, ensuring the the pairwise reciprocity is maintained. The sensitivity measure is the average Spearman's rank correlation of the vector of ranks of the principal eigenvectors of (i) the input PCM and (ii) the perturbed PCM. The average of the 500 such rank correlations is reported as the measure of sensitivity.
sensitivity(PCM, typePCM = TRUE)
sensitivity(PCM, typePCM = TRUE)
PCM |
A pairwise comparison matrix |
typePCM |
boolean flag indicating if the first argument is a PCM or a vector of upper triangular elements |
The average Spearman's rank correlation between the principal eigenvectors of the input and the perturbed 'PCMs'
revcons1 <- revisedConsistency(matrix( c(1,1/4,1/4,7,1/5, 4,1,1,9,1/4, 4,1,1,8,1/4, 1/7,1/9,1/8,1,1/9, 5,4,4,9,1), nrow=5, byrow=TRUE)) revcons1 sensitivity2 <- sensitivity(matrix( c(1,7,1,9,8, 1/7,1,1/6,7,9, 1,6,1,9,9, 1/9,1/7,1/9,1,5, 1/8,1/9,1/9,1/5,1), nrow=5, byrow=TRUE)) sensitivity2
revcons1 <- revisedConsistency(matrix( c(1,1/4,1/4,7,1/5, 4,1,1,9,1/4, 4,1,1,8,1/4, 1/7,1/9,1/8,1,1/9, 5,4,4,9,1), nrow=5, byrow=TRUE)) revcons1 sensitivity2 <- sensitivity(matrix( c(1,7,1,9,8, 1/7,1,1/6,7,9, 1,6,1,9,9, 1/9,1/7,1/9,1,5, 1/8,1/9,1/9,1/5,1), nrow=5, byrow=TRUE)) sensitivity2