pcX.Rd
Computes a paired-comparison design matrix.
pcX(nstimuli, omitRef = TRUE)
The design matrix can be used when fitting a Bradley-Terry-Luce (BTL)
model or a Thurstone-Mosteller (TM) model by means of glm
or lm
. See Critchlow and Fligner (1991) for more details.
A matrix having (nstimuli - 1)*nstimuli/2
rows and
nstimuli - 1
columns (if the reference category is omitted).
Critchlow, D.E., & Fligner, M.A. (1991). Paired comparison, triple comparison, and ranking experiments as generalized linear models, and their implementation in GLIM. Psychometrika, 56, 517–533. doi:10.1007/bf02294488
data(drugrisk) # absolute choice frequencies
btl <- eba(drugrisk[, , 1]) # fit Bradley-Terry-Luce model using eba
summary(btl)
#>
#> Parameter estimates:
#> Estimate Std. Error z value Pr(>|z|)
#> 1 0.013430 0.003359 3.998 6.39e-05 ***
#> 2 0.010447 0.002689 3.886 0.000102 ***
#> 3 0.006606 0.001794 3.683 0.000231 ***
#> 4 0.118607 0.021072 5.629 1.82e-08 ***
#> 5 0.427059 0.037799 11.298 < 2e-16 ***
#> 6 0.130363 0.022718 5.738 9.56e-09 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Model tests:
#> Df1 Df2 logLik1 logLik2 Deviance Pr(>Chi)
#> Overall 1 30 -300.17 -66.87 466.61 <2e-16 ***
#> EBA 5 15 -29.89 -24.02 11.73 0.304
#> Effect 0 5 -257.33 -29.89 454.88 <2e-16 ***
#> Imbalance 1 15 -42.84 -42.84 0.00 1.000
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> AIC: 69.775
#> Pearson X2: 10.19
y1 <- t(drugrisk[, , 1])[lower.tri(drugrisk[, , 1])]
y0 <- drugrisk[, , 1][ lower.tri(drugrisk[, , 1])]
## Fit Bradley-Terry-Luce model using glm
btl.glm <- glm(cbind(y1, y0) ~ 0 + pcX(6), binomial)
summary(btl.glm)
#>
#> Call:
#> glm(formula = cbind(y1, y0) ~ 0 + pcX(6), family = binomial)
#>
#> Coefficients:
#> Estimate Std. Error z value Pr(>|z|)
#> pcX(6)1 -0.2512 0.2145 -1.171 0.24161
#> pcX(6)2 -0.7095 0.2239 -3.169 0.00153 **
#> pcX(6)3 2.1784 0.2589 8.413 < 2e-16 ***
#> pcX(6)4 3.4595 0.3044 11.365 < 2e-16 ***
#> pcX(6)5 2.2729 0.2618 8.682 < 2e-16 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> (Dispersion parameter for binomial family taken to be 1)
#>
#> Null deviance: 466.61 on 15 degrees of freedom
#> Residual deviance: 11.73 on 10 degrees of freedom
#> AIC: 69.775
#>
#> Number of Fisher Scoring iterations: 4
#>
## Fit Thurstone Case V model using glm
tm.glm <- glm(cbind(y1, y0) ~ 0 + pcX(6), binomial(probit))
summary(tm.glm)
#>
#> Call:
#> glm(formula = cbind(y1, y0) ~ 0 + pcX(6), family = binomial(probit))
#>
#> Coefficients:
#> Estimate Std. Error z value Pr(>|z|)
#> pcX(6)1 -0.1574 0.1250 -1.259 0.20800
#> pcX(6)2 -0.4202 0.1297 -3.241 0.00119 **
#> pcX(6)3 1.2120 0.1347 8.999 < 2e-16 ***
#> pcX(6)4 1.9005 0.1567 12.131 < 2e-16 ***
#> pcX(6)5 1.2519 0.1357 9.229 < 2e-16 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> (Dispersion parameter for binomial family taken to be 1)
#>
#> Null deviance: 466.614 on 15 degrees of freedom
#> Residual deviance: 15.181 on 10 degrees of freedom
#> AIC: 73.226
#>
#> Number of Fisher Scoring iterations: 5
#>