gluc / ahp

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

Build the AHP file from the result of a survey #17

Closed Edouard-Legoupil closed 6 years ago

Edouard-Legoupil commented 6 years ago

Hi,

I am trying to build the AHP file from the result of a pairwise comparison survey.

Do you have an example for a script that would build the correct YAML format out of a data frame showing the results of a pairwise comparison survey?

Thanks a lot, Edouard

gluc commented 6 years ago

Hi Edouard,

Unfortunately I do not have such a script. Doing it generically for all possible problems might be difficult.

But if you have a specific problem at hand, it's certainly feasible.

I can think of the following possibilities:

  1. you can do what you suggest, i.e. create the YAML file programmatically from the responses collected. The definition of the YAML file is here: https://cran.r-project.org/web/packages/ahp/vignettes/file-format.html
  2. you can create the ahp data.tree structure directly. This is easier than it sounds, at least once you have read the data.tree documentation. Starting points to understand the ahp structure are the Load process, and the ahp:::GetPreferences_2 function

Personally, I would probably go for 2, as it's probably quicker to implement. Either way, depending on the structure of your input data, and the complexity of your problem, this might be a bit of work.

Good luck!

Christoph

gluc commented 6 years ago

I was thinking of a third way, some sort of hybrid:

  1. keep simple structure of AHP problem in file, with default preferences
  2. manipulate preferences in code, as per report

This gist illustrates how this works: https://gist.github.com/gluc/b03520be946a6d8dcff7b014ae2cfbc7

Edouard-Legoupil commented 6 years ago

Dear Christoph,

Thanks for your reply.. I went for option 1 as I am looking at building a work-flow from the expert consultation survey till the compilation of results...

I have made various test: my script is here: https://github.com/unhcr-mena/analytic-hierarchy-process/blob/gh-pages/code/2-build-hierarchy.R

as of now, it creates a YAML file: https://github.com/unhcr-mena/analytic-hierarchy-process/blob/gh-pages/data/4-write-test-final.ahp (still need to take out the single quote wrapping)

I tried to tweak this file here:

It's not working... Any hint?

Thanks a lot Edouard