gluc / ahp

Analytical Hierarchy Process (AHP) with R
98 stars 41 forks source link

Priorities derivation difference with Saaty's publication #4

Closed RP87 closed 8 years ago

RP87 commented 8 years ago

Hi, I can't match the results of Saaty's publication. Decision making — the Analytic Hierarchy and Network Processes (AHP/ANP)

From the article (table 3: "Criteria weights with respect to the goal")

The following Priorities

 0.152
 0.433
 0.072
 0.305
 0.038

are given for the following matrix :

1   1/5     3   1/2     5
5   1   7   1   7
1/3     1/7     1   1/4     3
2   1   4   1   7
1/5     1/7     1/3     1/7     1

In R code :

Culture = c(1,1.0/5,3,1.0/2,5)
Family = c(5,1,7,1,7)
Housing = c(1.0/3,1.0/7,1,1.0/4,3)
Job = c(2,1,4,1,7)
Transportation = c(1.0/5,1.0/7,1.0/3,1.0/7,1)

mat = data.frame(Culture,Family,Housing,Job,Transportation)

PrioritiesFromPairwiseMatrixEigenvalues(mat, allowedConsistency = 0.051)
$priority
         1          2          3          4          5
0.12655215 0.04583010 0.26119217 0.05845164 0.50797395

$consistency
[1] 0.05027572

# the consistency trigger seems all right but values for priorities are different.
# alternative priorities derivation do not bring the article's values.

> PrioritiesFromPairwiseMatrixMeanNormalization(mat)
$priority
[1] 0.13099959 0.04873300 0.26082227 0.05945257 0.49999257

$consistency
[1] NA

> PrioritiesFromPairwiseMatrixGeometricMean(mat)
$priority
[1] 0.12473441 0.04501646 0.26341235 0.06047375 0.50636303

$consistency
[1] NA

Hope the issue is on my side. Double checking would be nice.

(Ubuntu 14.04 ; Rstudio 0.98.1062 ; don't know command line to list all linked packages with versions : do not hesitate to indicate command to be run for useful further informations)

BR Rudy

gluc commented 8 years ago

@RP87 : Hmm, unfortunately I have no access to the paper. I did double check though, and I can confirm your results. I did check 2 things, though:

To be completely honest with you, I'm far from being the ultimate capacity in the field, so any feedback from the community is more than welcome.

RP87 commented 8 years ago

Hi, I'm myself no maths star. But I suppose will improve while digging into this.

It troubles me that you confirmed my results with the previously proposed matrix. On my side I checked wikipedia's case (here below) and thought the issue was from my ahp (and dependencies) installation. But then you should have get a different result from mine on Saaty's example.

> cost = c(1,3,3,7)
> safety = c(1.0/3,1,1,9)
> capacity = c(1.0/3,1,1,7)
> style = c(1.0/7,1.0/9,1.0/7,1)
> mat = data.frame(cost,safety,capacity,style)
> PrioritiesFromPairwiseMatrixEigenvalues(mat, allowedConsistency = 1)
$priority
        1         2         3         4
0.0561392 0.1148294 0.1201882 0.7088432

$consistency
[1] 0.07379078

> PrioritiesFromPairwiseMatrixMeanNormalization(mat)
$priority
[1] 0.05970684 0.12230233 0.12798415 0.69000668

$consistency
[1] NA

> PrioritiesFromPairwiseMatrixGeometricMean(mat)
$priority
[1] 0.05455313 0.11678162 0.12435425 0.70431100

$consistency
[1] NA

I also looked at the pmr documentation and something puzzles me in the arguments :

dset an “A” matrix. It should be a square matrix with diagonal values equal 1 and $a_ij = 1/a_ij$. It has no interaction with the current divergent results (this condition is ok with the example from table 3 in Saaty's publication) but it could be an issue for me when a_ij != 1/a_ij. (ex : 4 vs 1/5 instead of 1/4).

I'll send you a spreadsheet with alternative checking.

CU Rudy

gluc commented 8 years ago

Hi, I only have little time to check today, but I think you have your matrix transposed, because the data.frame will assemble by column. Try this instead:

cost = c(1,3,3,7)
safety = c(1.0/3,1,1,9)
capacity = c(1.0/3,1,1,7)
style = c(1.0/7,1.0/9,1.0/7,1)
nms <- c("cost", "safety", "capacity", "style")
mat <- matrix(c(cost, safety, capacity, style), nrow = 4, byrow = TRUE, dimnames = list(nms, nms))

PrioritiesFromPairwiseMatrixEigenvalues(mat)

And you should get:

$priority
      cost     safety   capacity      style 
0.51007502 0.23435219 0.21505404 0.04051875 

$consistency
[1] 0.07379078
RP87 commented 8 years ago

You nailed it.

It was the use of data.frame that puts data in column.

Thanks.