Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sensitivity analysis #5

Open
ghost opened this issue Nov 28, 2016 · 4 comments
Open

Sensitivity analysis #5

ghost opened this issue Nov 28, 2016 · 4 comments

Comments

@ghost
Copy link

ghost commented Nov 28, 2016

Enhancement request:
Is there any interest in adding one or more methods for performing sensitivity analysis on the results? The paper A Sensitivity Analysis Approach for Some Deterministic Multi-Criteria Decision Making Methods, for example, presents a few techniques.

@gluc
Copy link
Owner

gluc commented Dec 12, 2016

Yes, that's been requested before. I am very open for pull requests!

@ravikiranrv
Copy link

Hi,
The shinny AHP app is a very good tool for solving AHP Problems. It would be also great if we can add sensitivity analysis on the results which can make this package a complete suite for decision making.

@ghost
Copy link
Author

ghost commented Jan 7, 2017

Prototyping some ideas here. These manipulate the trees differently from the rest of package code, and they could be nonsense, so it is not contribution-ready.

# Brainstorming some sensitivity charts
library(dplyr)
library(magrittr)
library(tidyr)
library(ggplot2)
library(ahp)


# reuse the car example
ahpFile <- system.file("extdata","car.ahp",package="ahp")
carAhp <- Load(ahpFile)
Calculate(carAhp)

# variant a
# the Hurley method scales the preferences by some coefficient
# priorities obtained from scaled pairwise weights
coefficient_range <- seq(0.1,2.0,0.1)
original <- carAhp$preferences$children$DecisionMaker$pairwiseMatrix$preferences

df <- bind_rows(sapply(coefficient_range, function(j) {
  weights <- original ^ j
  priorities <- PrioritiesFromPairwiseMatrixEigenvalues(weights)
  data.frame(Coefficient=j,t(priorities$priority))
},simplify=FALSE))

# reorganize for plotting
tdf <- df %>% gather(Preference,Weight,-Coefficient)

p <- ggplot(tdf,aes(x=Coefficient,y=Weight,color=Preference)) +
  geom_line() +
  scale_y_continuous(limits=c(0,1)) +
  geom_vline(xintercept=1.0,linetype="dashed") +
  labs(title = "Priorities from Pairwise Matrix Eigenvalues",
       caption = "Hurley-method sensitivity analysis",
       x=expression(paste("Coefficient ",alpha)))
p

# variant b
# manipulating the decision-maker preferences
# scaled coefficient range reused
# not strictly a Hurley variant because it can result in rank reversal
# reload the model 
carAhp <- Load(ahpFile)
Calculate(carAhp)
original <- carAhp$preferences$DecisionMaker$pairwise$preferences$preference

df <- bind_rows(sapply(coefficient_range, function(j) {
  scaled <- original ^ j
  carAhp$preferences$DecisionMaker$pairwise$preferences$preference <- scaled
  Calculate(carAhp)
  adf <- Analyze(carAhp,decisionMaker="Total",variable="weightContribution",sort="orig")
  adf %<>% select(-1,-Weight)
  if ( "Inconsistency" %in% colnames((adf)))
    adf %<>% select(-Inconsistency)
  data.frame(Coefficient=j,adf[1,])
},simplify=FALSE))

# reorganize for plotting
tdf <- df %>% gather(Priority,Weight,-Coefficient)

p <- ggplot(tdf,aes(x=Coefficient,y=Weight,color=Priority)) +
  geom_line() +
  geom_vline(xintercept=1.0,linetype="dashed") +
  labs(title = "Priority by Scaled Pairwise Preferences",
       y="Weight Contribution",
       x=expression(paste("Coefficient ",alpha)))
p

ppme

pspp

@juntianusj
Copy link

Hello,

Is there any development on sensitivity to this package? I would like to see if there is any.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants