Package 'AHPtools'

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

Help Index


Saaty CR Consistency

Description

Computes and returns the Consistency Ratio for an input PCM and its boolean status of consistency based on Consistency Ratio

Usage

CR(PCM, typePCM = TRUE)

Arguments

PCM

A pairwise comparison matrix

typePCM

boolean flag indicating if the first argument is a PCM or a vector of upper triangular elements

Value

A list of 3 elements, a boolean for the 'CR' consistency of the input 'PCM', the 'CR' consistency value and the principal eigenvector

Examples

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

Simulated Logical Pairwise Comparison Matrix for the Analytic Hierarchy Process

Description

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

Usage

createLogicalPCM(ord, prefVec = rep(NA, ord))

Arguments

ord

The desired order of the Pairwise Comparison Matrix

prefVec

The preference vector of length as the order of the input matrix

Value

A Logical Pairwise Comparison Matrix

Examples

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 for Analytic Hierarchy Process from a vector of length n(n-1)/2 comparison ratios

Description

Create a Pairwise Comparison Matrix of order n from a vector of length n(n-1)/2 independent upper triangular elements

Usage

createPCM(vec)

Arguments

vec

The preference vector of length as the order of the 'PCM'

Value

A Pairwise Comparison Matrix corresponding to the upper triangular elements

Examples

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));

Improve the CR consistency of a PCM

Description

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.

Usage

improveCR(PCM, typePCM = TRUE)

Arguments

PCM

A pairwise comparison matrix

typePCM

boolean flag indicating if the first argument is a PCM or a vector of upper triangular elements

Value

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

Examples

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

Evaluate Revised Consistency

Description

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.

Usage

revisedConsistency(PCM, typePCM = TRUE)

Arguments

PCM

A pairwise comparison matrix

typePCM

boolean flag indicating if the first argument is a PCM or a vector of upper triangular elements

Value

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

Examples

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

Compute Sensitivity

Description

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.

Usage

sensitivity(PCM, typePCM = TRUE)

Arguments

PCM

A pairwise comparison matrix

typePCM

boolean flag indicating if the first argument is a PCM or a vector of upper triangular elements

Value

The average Spearman's rank correlation between the principal eigenvectors of the input and the perturbed 'PCMs'

Examples

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