Impute missing observations using the maximum deviation method.
Source:R/ahp_missing.R
ahp.missing.RdImputes the missing values of a list of matrices produced by ahp.mat using the maximum deviation method. Missing values must be coded as NA. A minimum of n-1 comparisons must be made, where n is the number of attributes (assuming that the decision-maker is perfectly consistent). Note that the algorithm assumes that the NA values will be imputed under perfect consistency with the other pairwise comparisons made.
Arguments
- ahpmat
A list of pairwise comparison matrices of each decision maker generated by
ahp.mat.- atts
A list of attributes in the correct order
- round
Rounds the imputation values of the matrix to the nearest integer if
TRUE. Defaults toFALSE.- limit
If set to
TRUE, if the imputation value is larger than 9 or smaller than 1/9, the value is converted to 9 and 1/9 respectively. Defaults toFALSE.
Examples
library(magrittr)
atts <- c('cult', 'fam', 'house', 'jobs', 'trans')
data(city200)
set.seed(42)
## Make a dataframe that is missing at random
missing.df <- city200[1:10,]
for (i in 1:10){
missing.df[i, round(stats::runif(1,1,10))] <- NA
}
missingahp <- ahp.mat(missing.df, atts, negconvert = TRUE)
ahp.missing(missingahp, atts)
#> [[1]]
#> cult fam house jobs trans
#> cult 1.0000000 0.500 2.0000000 0.500 6.000000
#> fam 2.0000000 1.000 4.0000000 4.000 8.000000
#> house 0.5000000 0.250 1.0000000 0.250 2.243894
#> jobs 2.0000000 0.250 4.0000000 1.000 8.000000
#> trans 0.1666667 0.125 0.4456538 0.125 1.000000
#>
#> [[2]]
#> cult fam house jobs trans
#> cult 1.00 0.500 4.000000 1.0000000 4.000000
#> fam 2.00 1.000 4.000000 2.0000000 8.000000
#> house 0.25 0.250 1.000000 0.2500000 1.538966
#> jobs 1.00 0.500 4.000000 1.0000000 7.000000
#> trans 0.25 0.125 0.649787 0.1428571 1.000000
#>
#> [[3]]
#> cult fam house jobs trans
#> cult 1.0000000 0.2500000 2.0000000 1.0000000 3.125521
#> fam 4.0000000 1.0000000 7.0000000 3.0000000 5.000000
#> house 0.5000000 0.1428571 1.0000000 0.2500000 3.000000
#> jobs 1.0000000 0.3333333 4.0000000 1.0000000 6.000000
#> trans 0.3199467 0.2000000 0.3333333 0.1666667 1.000000
#>
#> [[4]]
#> cult fam house jobs trans
#> cult 1.00 0.1250000 4.0000000 0.3333333 4
#> fam 8.00 1.0000000 8.0000000 1.0000000 7
#> house 0.25 0.1250000 1.0000000 0.1742680 3
#> jobs 3.00 1.0000000 5.7382886 1.0000000 9
#> trans 0.25 0.1428571 0.3333333 0.1111111 1
#>
#> [[5]]
#> cult fam house jobs trans
#> cult 1.0000000 0.33333333 3.0000000 0.2000000 6.00000
#> fam 3.0000000 1.00000000 8.0000000 1.0000000 12.39224
#> house 0.3333333 0.12500000 1.0000000 0.2500000 3.00000
#> jobs 5.0000000 1.00000000 4.0000000 1.0000000 6.00000
#> trans 0.1666667 0.08069565 0.3333333 0.1666667 1.00000
#>
#> [[6]]
#> cult fam house jobs trans
#> cult 1.00 0.1666667 4.0000000 0.5000000 4
#> fam 6.00 1.0000000 7.0000000 1.6561412 4
#> house 0.25 0.1428571 1.0000000 0.2500000 3
#> jobs 2.00 0.6038132 4.0000000 1.0000000 6
#> trans 0.25 0.2500000 0.3333333 0.1666667 1
#>
#> [[7]]
#> cult fam house jobs trans
#> cult 1.0000000 0.1428571 5.0000000 3.0000000 3
#> fam 7.0000000 1.0000000 8.0000000 1.0000000 9
#> house 0.2000000 0.1250000 1.0000000 0.3246012 3
#> jobs 0.3333333 1.0000000 3.0807030 1.0000000 7
#> trans 0.3333333 0.1111111 0.3333333 0.1428571 1
#>
#> [[8]]
#> cult fam house jobs trans
#> cult 1.0000000 0.2000000 1.738206 0.3333333 5
#> fam 5.0000000 1.0000000 6.000000 3.0000000 8
#> house 0.5753057 0.1666667 1.000000 0.2500000 2
#> jobs 3.0000000 0.3333333 4.000000 1.0000000 7
#> trans 0.2000000 0.1250000 0.500000 0.1428571 1
#>
#> [[9]]
#> cult fam house jobs trans
#> cult 1.0000000 0.33333333 3.0000000 0.5000000 4.00000
#> fam 3.0000000 1.00000000 6.0000000 2.0000000 15.49362
#> house 0.3333333 0.16666667 1.0000000 0.2500000 3.00000
#> jobs 2.0000000 0.50000000 4.0000000 1.0000000 9.00000
#> trans 0.2500000 0.06454268 0.3333333 0.1111111 1.00000
#>
#> [[10]]
#> cult fam house jobs trans
#> cult 1.0000000 0.1428571 3.0000000 0.3333333 6.00000
#> fam 7.0000000 1.0000000 8.0000000 3.0000000 29.08228
#> house 0.3333333 0.1250000 1.0000000 0.2500000 3.00000
#> jobs 3.0000000 0.3333333 4.0000000 1.0000000 8.00000
#> trans 0.1666667 0.0343852 0.3333333 0.1250000 1.00000
#>