c5ml {lazy.mdpref}R Documentation

ML Solution to Thurstone Case V of Paired Comparison Data with logistic probability

Description

ML Solution to Thurstone Case V of Paired Comparison Data with logistic probability

Usage

c5ml(f, n, ij, sname = NULL, minp = 1e-09, lmax = 50, eps = 1e-06, print = 1)

Arguments

f

vector of # of times that the left object was preferred.

n

vector of # of trials per pair or scalar .

ij

matrix indicating the stimulus pair: i, j. When sname is NULL the elements of ij will be used as the names.

minp

minimum value of probability when n=1.

lmax

max # of iterations.

eps

criterion for convergence.

print

= 1 to print result.

Details

f_ij is the # of times that sutimulus i is preferred over stimulus j out of n_ij comparisons.
f_ij is assumed to have binomial distribution win n_ij and p_ij
where p_ij = logistic( x_i - x_j ).

Let P_{ij} be the probability that stimulus is preferred to stimulus j.
Thurstone Case V assumes that
 P_{ij} = Pr(Y_i > Y_j) where Y_i = x_i + E_i and
 E_i is N(0,s^2) for i,j = 1,2,...,N. Therefore,
 P_{ij} = Pr(Y_i-Y_j > 0) = Phi( (x_i-x_j) / 2s )
Assuming s=0.5, this function maximizes the following log likelihood:
 llh = sum_{i>j} f_{ij} log P_{ij} + (n_{ij}-f_{ij}) (1-log P_{ij})
where
  P_{ij} = Phi( (x_i-x_j) ) == logistic( 1.7 (x_i-x_j) )
with respect to the scale values x_i, i=1,2,...,N.

Standardized scale values with zero mean and unit variance will also be
reported.

Value


x The scale value
sname Stimulus name
n2o Name conversion table
llh log likelihood
maxag max value of the gradient vector
varx The variance of the scale values
errorvar The variance of the error term associated with x
xs Scale values normalized to have unit variance
errorvars The variance of the error term associated with xs
xls LS scale values
errorvalls The variance of xls
iter # of iterations used.
eps The convergence criterion

Examples


set.seed(1701)
x <- seq(-3,3,1) / 4
ns <- length(x)
npair <- ns*(ns-1)/2
ij <- vechindex(ns,nodiag=1, type=2)
ijc <- t( apply(max(ij)-ij,1, function(x) paste("s",x,sep="")) )
G <- t( apply( ij, 1
        , function(x){ g=numeric(ns); g[x[1]]=1; g[x[2]]=-1; return(g)} ) )
z <- G%*%x
p <- logistic(z)
n <- rep(c(5,3),npair)[1:npair]
f <- mapply( function(size,prob){ rbinom(1,size,prob) }, n, p )

locmiss <- c(1,4,9)
p <- p[-locmiss]
f <- f[-locmiss]
n <- n[-locmiss]
z <- z[-locmiss]
ij <- ij[-locmiss,]
ijc <- ijc[-locmiss,]
Print(ij, z,p,n,f,f/n)


res1=c5ls( f, n, ij )
res1=c5ls( f, n, ij, sname=paste("ss",1:ns,sep="") )
res1=c5ls( f, n, ijc )

res2=c5ml( f, n, ij )
res2=c5ml( f, n, ij, sname=paste("ss",1:ns,sep="") )
res2=c5ml( f, n, ijc )



[Package lazy.mdpref version 0.1.4 Index]