make.ix.mat {MLDS} | R Documentation |
Create data.frame for Fitting Difference Scale by glm
Description
make.ix.mat
generates a n x p
matrix from the n x 5
column data.frame storing the results of a difference scaling experiment, where p
is the number of stimulus levels tested and n
is the number of trials. The first column is the response (0 or 1), and the p - 1
succeeding columns code covariates for all but the first stimulus level, which is contrained to be 0. These columns take the value 0 unless the stimulus level was in the trial, in which case they take, in order, the values, 1, -1, -1, 1.
Usage
make.ix.mat(data, xi = NULL, ...)
Arguments
data |
a 5 column data.frame. The first column is the |
xi |
an integer indicating the number of stimulus levels tested. If this is NULL, it is determined from the maximum value in |
... |
Other arguments, not used for the moment. |
Details
To fit a difference scale using mlds
and method
= “glm”, each stimulus level is treated as a covariate taking on the values 0, if it was not present in the trial, or -1 or 1, the latter two depending on the ordinal stimulus level within the trial. This is a helper function to transform the typical 5 column data.frame from a difference scaling experiment, indicating the response and the 4 stimulus levels, to one in the format described above. Matrices of this form can also be used as newdata
for the predict method. This is exploited in the function like6pt
. It is here that the argument xi
is necessary since the data.frame for the first of the 6-point comparisons does not contain the highest level of the scale and so needs to be specified so that the data.frame conforms with that used to generate the ‘mlds’ object.
Value
A data.frame withn
rows and p
columns.
resp |
The |
stim.2--stim.p |
Columns 2 through |
Note
In the current parameterization, the coefficient of the initial stimulus level is constrained to 0. Thus, the column corresponding to this level is left-out of the data.frame. For trials in which this stimulus is present, the non-zero elements are (-1, -1, 1), in that order.
Author(s)
Kenneth Knoblauch
See Also
Examples
data(AutumnLab)
make.ix.mat(AutumnLab)
mlds(AutumnLab, c(1, seq(6, 30, 3)))