patt.design: Paired Comparison Patterns - Design Matrix Generation

Description Usage Arguments Details Value Input Data Deprecated Author(s) References See Also Examples

Description

The function 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.

Usage

1
2
3
patt.design(obj, nitems = NULL, objnames = "", objcovs = NULL,
            cat.scovs = NULL, num.scovs = NULL, resptype = "paircomp",
            reverse = FALSE, ia = FALSE, casewise = FALSE, ...)

Arguments

obj

either a data frame or a data file name.

nitems

number of items (objects). nitems is not the number of comparisons!

objnames

an optional character vector with names for the objects. These names are the columns names in the output data frame. If objnames is not specified o1, o2, etc. will be used.

objcovs

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 model.matrix).

cat.scovs

a character vector with the names of the categorical subject covariates in the data file to be included into the design matrix. (example: cat.scovs = c("SEX", "WORK")). If all covariates in the data are categorical and should be included, the specification can be abbreviated to cat.scovs = "ALL". In that case, num.scovs must not be specified. For no categorical covariates: cat.scovs = "", the default.

num.scovs

analogous to cat.scovs for numerical (continuous) subject covariates. If any numerical covariates are specified, casewise is set to TRUE.

resptype

one of "paircomp", "rating", or "ranking".

reverse

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 reverse should be specified to be FALSE, the default. Otherwise set reverse = TRUE. The only exception is paired comparison responses that are coded -1/1, -1/0/1, -2/-1/0/1/2, etc. Then negative numbers are treated as not preferred. (See Input Data below)

ia

generates covariates for interactions between comparisons if ia = TRUE.

casewise

If casewise = TRUE a separate design structure is set up for each subject in the data. This is required when fitting continuous subject covariates. However, the design can become very large in the case of many subjects and/or comparisons. See Details below.

...

deprecated options to allow for backwards compatibility (see Deprecated below).

Details

The function patt.design allows for different scenarios mainly concerning

Value

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 Y. The next columns are the covariates for the items and the undecided category effects (one for each comparison). These are labelled as u12, u13, etc., where 12 denotes the comparison between items 1 and 2. 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 a. If subject covariates are present they are in the rightmost columns and defined to be factors.

Input Data

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 pattPC.fit, pattL.fit, or pattR.fit instead).

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 A, B, and 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. For ratings. 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 xmpl.

(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.)

Deprecated

The following options are for backwards compatibility and should no longer be used.

blnCasewise

same as casewise.

blnIntcovs

same as ia.

blnRevert

same as reverse.

cov.sel

same as cat.scovs.

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.

Author(s)

Reinhold Hatzinger

References

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.

See Also

llbt.design, pattPC.fit, pattL.fit, pattR.fit

Examples

 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))

Example output

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

prefmod documentation built on May 2, 2019, 4:59 p.m.