knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
The ahpsurvey
package provides a consistent methodology for researchers to reformat data and run the analytic hierarchy process (AHP), introduced by Thomas Saaty, on data that are formatted with the survey data entry mode. It is optimised for performing the AHP with many decision-makers, and provides tools and options for researchers to aggregate individual preferences and concurrently test multiple aggregation options. It also allows researchers to quantify, visualise and correct for inconsistent pairwise comparisons.
Install ahpsurvey
directly from CRAN:
install.packages("ahpsurvey",repos = "http://cran.us.r-project.org")
Or, install the development version of ahpsurvey
from Github with:
# install.packages("devtools") devtools::install_github("frankiecho/ahpsurvey")
The ahpsurvey
allows one to input a data.frame
consisting of pairwise comparisons data collected through questionnaires and output an informative output of the aggregated priorities of all observations, the individual priorities, consistency ratios, and the most inconsistent pairwise comparisons.
library(ahpsurvey) library(magrittr) data(city200) city200 %>% head()
Take a data.frame
like that above and calculate the aggregated priorities of the 200 decision-makers.
## Define the attributes used output <- ahp(city200, atts <- c("cult", "fam", "house", "jobs", "trans"), negconvert = TRUE, agg = TRUE) output$aggpref
And can show the detailed individual priorities of the 200 decision-makers and the consistency ratio of each decision-maker using that list:
head(output$indpref)[1:6]
Further arguments allow you to specify the aggregation method, impute missing values and identify and correct inconsistent responses.
An overview of the functions in this package are as follows:
ahp
: A canned AHP routineahp.mat
: Generate AHP pairwise matrices from survey dataahp.indpref
: Priority weights of individual decision-makersahp.aggpref
: Aggregate individual priorities (AIP)ahp.aggjudge
: Aggregate individual judgements (AIJ)ahp.cr
: Saaty's Consistency Ratioahp.error
: The product between the pairwise comparison value and pj/piahp.pwerror
: Finds the pairwise comparisons with the maximum amount of inconsistencyahp.missing
: Impute missing pairwise comparsionsahp.md
: Replace inconsistent pairwise comparisonsFor a detailed example of how the above function works, look no further than the vignettes, which are stored in /my-vignette.pdf
. There, you can find a detailed step-by-step instruction of how to use the function using a simulated survey dataset and visualise the output using ggplot2
.
I have plans to add the following features in the future, perhaps after I finish writing up my masters thesis :-(
Please let me know if there are any features which could be useful to you in a feature request or contribution.
This project is licensed under the MIT License.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.