patt.design converts (i) real paired comparison responses, or (ii) a set of ratings (or Likert-type responses measured on a common scale), or (iii) full rankings into paired comparison patterns, returning a new data frame containing the design matrix for a loglinear paired comparison model.
Additionally, the frequencies of these patterns are computed and are stored in the first column of the data frame.
1 2 3
either a data frame or a data file name.
number of items (objects).
an optional character vector with names for the objects.
These names are the columns names in the output data frame.
an optional data frame with object specific covariates.
The rows correspond to the objects, the columns define the covariates.
The column names of this data frame are later used to fit the covariates.
Factors are not allowed.
In that case dummy variables have to be set up manually (favourably using
a character vector with the names of the categorical subject covariates in the data file to be included into the design matrix.
If the responses are such that low values correspond to high preference (or agreement or rank) and high values to low preference (or agreement or ranks) (e.g., (1) I strongly agree ... (5) I strongly disagree) then
generates covariates for interactions between comparisons if
deprecated options to allow for backwards compatibility (see Deprecated below).
patt.design allows for different scenarios mainly concerning
responses. Currently, three types of responses can be specified.
paired comparison data. Responses can be either simply preferred – not preferred or ordinal (strongly preferred – ... – not at all preferred). In both cases an undecided category may or may not occur. If there are more than three categories a they are reduced to two or three response categories. The set of paired comparison responses represents a response pattern.
ratings/Likert type responses. The responses to Likert type items are transformed to paired comparison responses by calculating the difference between each pair of the Likert items. This leads to an ordinal (adjacent categories) paired comparison model with 2k-1 response categories where k is the number of the (original) Likert categories. Again, the transformed ratings are reduced to three response categories (preferred – undecided – not preferred).
rankings. Currently only full rankings are allowed, i.e., a (consecutive) integer must uniquely be assigned to each object in a list according to the (subjective) ordering. Ties are not allowed. As for ratings, the rankings are transformed to paired comparison responses by calculating the difference between each pair of the ranks. Again a category reduction (as described above) is automatically performed.
The design matrix for the basic model has columns for the items (objects) and (depending on the type of responses) for undecided comparisons.
For ratings (Likert type) undecided comparisons occur if any subject has responded to two items in the same category.
For paired comparisons it depends on the design.
For rankings there are no undecided categories.
If undecided categories occur there is one dummy variable for each comparison.
Additionally, covariates for two way interaction between comparisons (i.e., for effects resulting from the dependence between two comparisons that have one item in common) can be obtained by setting
ia = TRUE.
object specific covariates.
For modelling certain characteristics of objects a reparameterisation can be included in the design.
This is sometimes called conjoint analysis.
The object specific covariates can be continuous or dummy variables.
For the specification see Argument
subject covariates. For modelling different preference scales for the items according to characteristics of the respondents categorical subject covariates can be included in the design. The corresponding variables are defined as numerical vectors where the levels are specified with consecutive integers starting with 1. This format must be used in the input data file and is also used in all outputs.
The output is a dataframe. Each row represents a unique response pattern. If subject covariates are specified, each row instead represents a particular combination of a unique covariate combination with a response pattern. All possible combinations are generated.
The first column contains the counts for the paired comparison response patterns and is labelled with
The next columns are the covariates for the items and the undecided category effects (one for each comparison).
These are labelled as
u13, etc., where
12 denotes the comparison between items
Optionally, covariates for dependencies between comparisons follow.
The columns are labelled
Ia.bc denoting the interaction of the comparisons between items
(a, b) and
(a, c) where the common item is
If subject covariates are present they are in the rightmost columns and defined to be factors.
Responses have to be coded as consecutive integers (e.g., (0, 1), or (1, 2, 3, ...), where the smallest value corresponds to (highest) preference for the first object in a comparison.
For (ordinal) paired comparison data (
resptype = "paircomp") the codings (1, -1), (2, 1, -1, -2), (1, 0, -1), (2, 1, 0, -1, -2) etc. can also be used.
Then negative numbers correspond to not preferred, 0 to undecided.
Missing responses are not allowed (use functions
Input data (via the first argument
obj in the function call) is specified either through a dataframe or a datafile in which case
obj is a path/filename.
The input data file if specified must be a plain text file with variable names in the first row as readable via the command
read.table(datafilename, header = TRUE).
The leftmost columns must be the responses to the paired comparisons, ratings (Likert items), or rankings.
For paired comparisons the mandatory order is of comparisons is (12) (13) (23) (14) (24) (34) (15) (25) etc. For rankings, the lowest value means highest rank according to the underlying scale.
Each column in the data file corresponds to one of the ranked objects.
For example, if we have 3 objects denoted by
C, with corresponding columns in the data matrix, the response pattern
(3, 1, 2) represents: object
B ranked highest,
C ranked second, and
A ranked lowest.
again the lowest value means highest ‘endorsement’ (agreement) according to the underlying scale.
All items are assumed to have the same number of response category.
The columns for responses are optionally followed by columns for subject covariates.
If categorical, they have to be specified such that the categories are represented by consecutive integers starting with 1.
Missing values are not allowed and treated such that rows with
NAs are removed from the resulting design structure and a message is printed.
For an example see
(Besides supplying data via a dataframe or a datafile name,
obj can also be specified as a control list with the same elements as the arguments in the function call.
The data must then be specified as a path/filename using the element
datafile = "filename".
The control list feature is deprecated.
An example is given below.)
The following options are for backwards compatibility and should no longer be used.
Options for requesting GLIM commands and data structures are no longer supported.
Specifying the input to
llbt.design via a control list is also deprecated.
If you want to use these features you have to install prefmod <= 0.8-22.
Dittrich, R., Francis, B.J., Hatzinger R., Katzenbeisser, W. (2007), A Paired Comparison Approach for the Analysis of Sets of Likert Scale Responses. Statistical Modelling, Vol. 7, No. 1, 3–28.
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
# mini example with three Likert items and two subject covariates dsgnmat <- patt.design(xmpl, nitems = 3, resptype = "rating", ia = TRUE, cov.sel = "ALL") head(dsgnmat) # ILLUSTRATING THE ISSP2000 EXAMPLE # simplified version of the analysis as given in Dittrich et. al (2007). design <- patt.design(issp2000, nitems = 6, resptype = "rating", cov.sel = c("SEX", "EDU")) # - fit null multinomial model (basic model for items without subject # covariates) through Poisson distribution. # - SEX:EDU parameters are nuisance parameters # - the last item (GENE) becomes a reference item in the model and is aliased; # all other items are compared to this last item # item parameters with undecided effects and no covariate effects. summary(glm(y ~ SEX*EDU + CAR+IND+FARM+WATER+TEMP+GENE + u12+u13+u23+u14+u24+u34+u15+u25+u35+u45+u16+u26+u36+u46+u56, data = design, family = poisson)) # now add main effect of SEX on items summary(glm(y ~ SEX:EDU + CAR+IND+FARM+WATER+TEMP+GENE + (CAR+IND+FARM+WATER+TEMP+GENE):SEX + u12+u13+u23+u14+u24+u34+u15+u25+u35+u45+u16+u26+u36+u46+u56, data = design, family = poisson))
Loading required package: gnm Loading required package: colorspace y I1 I2 I3 u12 u13 u23 I12.13 I12.23 I13.23 SEX EDU 1 2 0 0 0 1 1 1 0 0 0 1 1 2 4 1 1 -2 1 0 0 0 0 1 1 1 3 2 1 -2 1 0 1 0 0 -1 0 1 1 4 2 2 -1 -1 0 0 1 1 0 0 1 1 5 1 2 0 -2 0 0 0 1 1 1 1 1 6 2 2 -2 0 0 0 0 1 -1 -1 1 1 Call: glm(formula = y ~ SEX * EDU + CAR + IND + FARM + WATER + TEMP + GENE + u12 + u13 + u23 + u14 + u24 + u34 + u15 + u25 + u35 + u45 + u16 + u26 + u36 + u46 + u56, family = poisson, data = design) Deviance Residuals: Min 1Q Median 3Q Max -6.4213 -0.3207 -0.2205 -0.1535 4.9170 Coefficients: (1 not defined because of singularities) Estimate Std. Error z value Pr(>|z|) (Intercept) -4.526950 0.065791 -68.808 < 2e-16 *** SEX2 0.411507 0.061472 6.694 2.17e-11 *** EDU2 -0.622943 0.080685 -7.721 1.16e-14 *** CAR 0.064210 0.011566 5.551 2.83e-08 *** IND -0.134930 0.012429 -10.856 < 2e-16 *** FARM 0.004887 0.012514 0.391 0.69617 WATER -0.038560 0.011978 -3.219 0.00129 ** TEMP -0.050831 0.012369 -4.110 3.96e-05 *** GENE NA NA NA NA u12 1.270165 0.066467 19.110 < 2e-16 *** u13 0.365356 0.076157 4.797 1.61e-06 *** u23 0.867787 0.072066 12.042 < 2e-16 *** u14 0.307585 0.076170 4.038 5.39e-05 *** u24 0.588040 0.073292 8.023 1.03e-15 *** u34 1.194840 0.063323 18.869 < 2e-16 *** u15 0.641683 0.070487 9.104 < 2e-16 *** u25 0.638590 0.071026 8.991 < 2e-16 *** u35 0.489905 0.072892 6.721 1.81e-11 *** u45 0.644672 0.070030 9.206 < 2e-16 *** u16 -0.111242 0.078242 -1.422 0.15509 u26 0.317241 0.077180 4.110 3.95e-05 *** u36 0.690532 0.069886 9.881 < 2e-16 *** u46 0.324214 0.072929 4.446 8.77e-06 *** u56 0.772761 0.065981 11.712 < 2e-16 *** SEX2:EDU2 -0.334076 0.109259 -3.058 0.00223 ** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 (Dispersion parameter for poisson family taken to be 1) Null deviance: 11419.5 on 15851 degrees of freedom Residual deviance: 4015.9 on 15828 degrees of freedom AIC: 5870.7 Number of Fisher Scoring iterations: 6 Call: glm(formula = y ~ SEX:EDU + CAR + IND + FARM + WATER + TEMP + GENE + (CAR + IND + FARM + WATER + TEMP + GENE):SEX + u12 + u13 + u23 + u14 + u24 + u34 + u15 + u25 + u35 + u45 + u16 + u26 + u36 + u46 + u56, family = poisson, data = design) Deviance Residuals: Min 1Q Median 3Q Max -6.2636 -0.3207 -0.2196 -0.1517 5.0330 Coefficients: (3 not defined because of singularities) Estimate Std. Error z value Pr(>|z|) (Intercept) -5.07094 0.07768 -65.282 < 2e-16 *** CAR 0.01746 0.01743 1.002 0.316419 IND -0.18742 0.01898 -9.872 < 2e-16 *** FARM -0.01991 0.01908 -1.043 0.296719 WATER -0.05975 0.01828 -3.268 0.001082 ** TEMP -0.10001 0.01893 -5.283 1.27e-07 *** GENE NA NA NA NA u12 1.26698 0.06650 19.052 < 2e-16 *** u13 0.36652 0.07617 4.812 1.50e-06 *** u23 0.86935 0.07210 12.057 < 2e-16 *** u14 0.30946 0.07619 4.062 4.87e-05 *** u24 0.59042 0.07333 8.051 8.19e-16 *** u34 1.19361 0.06333 18.847 < 2e-16 *** u15 0.63868 0.07051 9.058 < 2e-16 *** u25 0.63480 0.07106 8.933 < 2e-16 *** u35 0.49119 0.07292 6.736 1.63e-11 *** u45 0.64665 0.07007 9.229 < 2e-16 *** u16 -0.10540 0.07832 -1.346 0.178354 u26 0.32448 0.07728 4.199 2.69e-05 *** u36 0.68776 0.06997 9.830 < 2e-16 *** u46 0.32018 0.07300 4.386 1.15e-05 *** u56 0.77907 0.06611 11.785 < 2e-16 *** SEX1:EDU1 0.51313 0.08160 6.288 3.21e-10 *** SEX2:EDU1 0.95702 0.07367 12.990 < 2e-16 *** SEX1:EDU2 -0.10981 0.09286 -1.183 0.237001 SEX2:EDU2 NA NA NA NA SEX2:CAR 0.08096 0.02264 3.576 0.000349 *** SEX2:IND 0.09012 0.02429 3.710 0.000208 *** SEX2:FARM 0.04271 0.02481 1.722 0.085103 . SEX2:WATER 0.03637 0.02377 1.530 0.126073 SEX2:TEMP 0.08480 0.02459 3.449 0.000563 *** SEX2:GENE NA NA NA NA --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 (Dispersion parameter for poisson family taken to be 1) Null deviance: 11419.5 on 15851 degrees of freedom Residual deviance: 3991.7 on 15823 degrees of freedom AIC: 5856.5 Number of Fisher Scoring iterations: 6
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.