Generic function mlds
uses different methods to fit the results of a difference scaling experiment either using glm
(Generalized Linear Model), by direct maximization of the likelihood using optim
or by maximizing the likelihood with respect to a function of the stimulus dimension specified by a one sided formula.
mlds(x, ...)# S3 method for mlds.df
mlds(x, stimulus = NULL, method = "glm",
lnk = "probit", opt.meth = "BFGS", glm.meth = "glm.fit",
opt.init = NULL, control = glm.control(maxit = 50000, epsilon = 1e-14),
... )
# S3 method for mlbs.df
mlds(x, stimulus = NULL, method = "glm",
lnk = "probit",
control = glm.control(maxit = 50000, epsilon = 1e-14),
glm.meth = "glm.fit",
... )
# S3 method for data.frame
mlds(x, ... )
# S3 method for formula
mlds(x, p, data, stimulus = NULL,
lnk = "probit", opt.meth = "BFGS",
control = list(maxit = 50000, reltol = 1e-14), ... )
A list of class ‘mlds’ whose components depend on whether the method was specified as ‘glm’, ‘optim’ with the default method, or the formula method was used,
A numeric vector of the estimated difference scale.
The physical stimulus levels
The scale estimate, always 1.0 for ‘glm’
The fitting method
The binomial link specified, default ‘probit’
For method ‘glm’, an object of class ‘glm’ resulting from the fit.
for method ‘optim’, the logarithm of likelihood at convergence
for method ‘optim’, the Hessian matrix at convergence
For method‘optim’, the data.frame or ‘mlds.df’ entered as an argument.
For method ‘optim’, a code indicating whether optim
converged or not. See optim
.
For ‘formula’ method, the parameters estimated.
The one-sided formula specified with the ‘method’.
For ‘formula’ method, a function obtained from the one-sided formula
.
For comparisons of two pairs of stimuli, when the method
is specified as ‘glm’ or ‘optim’ a data frame with 5 columns giving the response and the ranks of the stimulus levels for each trial, or an object of class ‘mlds.df’ which also contains additional information as attributes. For comparisons of triples of stimuli, only the method ‘glm’ is currently defined. The object can be a data frame of 4 columns with the first specifying the response and the other 3 the stimulus level ranks, or an object of class ‘mlbs.df’, which contains additional attributes. It can also be a one-side formula with parameters p
and stimulus variable sx
that gives a parametric formula to fit to the data for the formula
method.
A data frame with 4 or 5 columns giving the response and the ranks of the stimulus levels for each trial, or an object of class ‘mlbs.df’ or ‘mlds.df’, respectively, which also contains additional information as attributes, required when the ‘formula’ method is used.
numeric vector of parameters of length one greater than the number of parameters in the formula
argument that specifies initial values for the parameters. The extra parameter, specified last, is the initial estimate of sigma
.
A numeric vector that contains the physical stimulus levels used in the experiment. If data
is of class ‘mlds.df’, this information is included as an attribute. If NULL
, a sequence of \(1:n\) is used, where n is the number of stimulus levels, deduced from the highest rank in data
.
character, taking the value of “glm” or “optim”. Default is “glm”.
character indicating either one of the built-in links for the binomial family or a user defined link of class ‘link-glm’. See family
and make.link
. Default is “probit”.
If method
= “optim”, the method used by optim
can be specified. Defaults to “BFGS”.
Vector of numeric giving initial values which must be provided if you specify the “optim” method.
A list of control values for either glm
or optim
. Since the method
defaults to “glm”, the default is a glm list but should be changed if the “optim” method is chosen.
the method to be used in fitting the model, only when method = glm
. The default value is “glm.fit”. Seeglm
for further details.
Additional arguments passed along to glm
or optim.
Kenneth Knoblauch and Laurence T. Maloney
Observers are presented with either triples or pairs of pairs of stimuli, distributed along a physical stimulus axis. For example, for stimuli \(a, b, c\) with \(a < b < c\), they see the triple \(a, b, c\), or for stimuli \(a, b, c, d\) with \(a < b < c < d\), they see the pairs \((a, b)\) and \((c, d)\). For each trial, they make a judgement respectivily as to whether the difference between stimuli 1 and 2 is greater or not that between stimuli 2 and 3 or the elements of pair 1 is greater or not than the difference between the elements of pair 2. From a large number of trials on different quadruples, mlds
estimates numbers, \(Psi_1,..., Psi_n\), by maximum likelihood such that \((Psi_d - Psi_c) > (Psi_b - Psi_a)\) when the observer chooses pair 2, and pair 1, otherwise.
If there are \(p\) stimulus levels tested, then \(p - 1\) coefficients are estimated. The “glm” method constrains the lowest estimated value, \(Psi_1 = 0\), while the “optim” method constrains the lowest and highest values to be 0 and 1, respectively. The “optim” method estimates an additional scale parameter, sigma
, whereas this value is fixed at 1.0 for the “glm” method. In principle, the scales from the two methods are related by
$$1/\sigma_o = max(Psi_g)$$
where \(\sigma_o\) is sigma
estimated with the “optim” method and \(Psi_g\) corresponds to the perceptual scale values estimated with the “glm” method. The equality may not be exact as the “optim” method prevents the selection of values outside of the interval [0, 1] whereas the “glm” method does not.
Maloney, L. T. and Yang, J. N. (2003). Maximum likelihood difference scaling. Journal of Vision, 3(8):5, 573--585, tools:::Rd_expr_doi("10.1167/3.8.5").
Knoblauch, K. and Maloney, L. T. (2008) MLDS: Maximum likelihood difference scaling in R. Journal of Statistical Software, 25:2, 1--26, tools:::Rd_expr_doi("10.18637/jss.v025.i02").
data(AutumnLab)
#Note the warnings generated by glm method
x.mlds <- mlds(AutumnLab)
summary(x.mlds)
y.mlds <- mlds(AutumnLab, method = "optim", opt.init = c(seq(0, 1, len = 10), 0.16))
summary(y.mlds)
plot(x.mlds)
#How sigma relates the scales obtained by the 2 different methods.
lines(y.mlds$stimulus, y.mlds$pscale/y.mlds$sigma)
#Example with triads
data(kktriad)
kkt.mlds <- mlds(kktriad)
plot(kkt.mlds, type = "b")
#An example using the formula method
data(kk1)
# with one parameter
kk.frm1 <- mlds(~ sx^p, p = c(3, 0.02), data = kk1)
# with two parameters
kk.frm2 <- mlds(~p[1] * (sx + abs(sx - p[2])) - p[1] * p[2],
p = c(0.9, 0.3, 0.2), data = kk1)
Run the code above in your browser using DataLab