Pmaker: Pairs matrix

Description Usage Arguments Details Value References See Also Examples

View source: R/makers.r

Description

Compute the pairs matrix for a full ranking of m objects

Usage

1
Pmaker(m)

Arguments

m

the number of objects

Details

This is the transpose of the pairs matrix presented in Marden (1995).

Value

...

References

Marden, J. I. (1995). Analyzing and Modeling Rank Data, London: Chapman & Hall. p.42.

See Also

Tmaker, Amaker, Emaker, Mmaker, Smaker

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
data(city)

Pmaker(3)
Pmaker(3) %*% city
# 1 = city, 2 = suburb, 3 = country

# looking just among city folk, generate the pairs matrix
city[,"city",drop=FALSE] # the data
m <- sum(city[,"city"])
k <- (Pmaker(3) %*% city)[,1]
Khat <- upper(k) + lower(m-k)
colnames(Khat) <- row.names(Khat) <- colnames(city)
Khat
round(Khat / m, 2) # % times row is rated over column


# worked out: city is voted over suburb in 123 , 132, and 231, equaling
210 + 23 + 8   # = Khat[1,2]
# whereas suburb is rated over city in 213, 312, 321, equaling
111 + 204 + 81 # = Khat[2,1]


# is there a condorcet choice?

p <- ncol(Khat)
Khat[which(diag(p) == 1)] <- NA
K2 <- t(apply(Khat, 1, function(v) v[!is.na(v)])) # remove diag elts
boole <- apply(K2/m, 1, function(x) all(x > .5))
if(any(boole)) names(boole)[which(boole)]
# suburb is a condorcet choice

algstat documentation built on May 29, 2017, 10:34 p.m.

Related to Pmaker in algstat...