patt.design {prefmod}R Documentation

Paired Comparison Patterns - Design Matrix Generation

Description

The function patt.design converts (i) real paired comparison responses, or (ii) a set of ratings (Likert type responses measured on a commmon 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. Optionally, the function provides all necessary structures (commands, data/design files) to fit the loglinear paired comparisons pattern model in GLIM, which is often more efficient at fitting large loglinear models of this type.

Usage

patt.design(obj, nitems = NULL, objnames = "", resptype = "paircomp",
     blnRevert = FALSE, cov.sel = "", blnIntcovs = FALSE,
     blnGLIMcmds = FALSE, glimCmdFile = "", outFile = "", intFile = "")

Arguments

obj either a data frame, a data file name, or a control object.
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 ouput data frame. If objnames is not specified consecutive letters starting with "a" will be used.
resptype one of "paircomp", "rating", or "ranking".
blnRevert If the responses are such that low values correspond to high preference or agreement and high values to low preference or agreement (e.g., (1) I strongly agree ... (5) I strongly disagree) then blnRevert should be specified to be FALSE. Otherwise set blnRevert = TRUE.
cov.sel a character vector with the names of the subject covariates in the data file to be included into the design matrix. (example: cov.sel = c("SEX", "AGE")). If all covariates are to be included the specification can be abbreviated to cov.sel = "ALL". For no covariates specify cov.sel = "".
blnIntcovs generates covariates for interactions between comparisons if blnIntcovs = TRUE.
blnGLIMcmds TRUE, if GLIM output is wanted. If blnGLIMcmds = FALSE the following items can be set to any value (such as a null text string) and are ignored. Please note that if blnGLIMcmds is set to be TRUE there is no output in R but instead goes to the the following files.
glimCmdFile name of the output file which will contain all necessary commands to fit a basic model (defining all structures and reading the necessary data).
outFile name of the data/design file to be read into GLIM. It consists of the response frequencies and the covariates for the objects, the undecided comparison responses and the subject effects.
intFile name of the design file for the interaction effects. This file is only generated if blnIntcovs = TRUE.

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.
Alternatively, the function patt.design does not produce output in R if GLIM output is requested via blnGLIMcmds = TRUE. The output is then written to the corresponding files (see The Control List below).

Input Data

Responses have to be coded as consecutive integers (e.g., (0,1), or (1,2,3,...). For paired comparison without undecided category (-1,1), or (1,0,-1) for paired comparison with an undecided category, can also be used ('-1' is the not preferred category).

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 cateory

The columns for responses are optionally followed by columns for categorical subject covariates. These have to be specified such that the categories are represented by consecutive integers starting with 1. Missing values are not allowed (use functions pattPC.fit, pattL.fit, or pattR.fit instead), and treated such that rows with NAs are removed from the resulting design structure and a message is printed. For an example see xmpl or the file xmpl.dat in the package's data/ directory.

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

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 2007; 7; 3

See Also

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

Examples


## mini example with three Likert items
## and two subject covariates

data(xmpl)   # example data in package
dsgnmat <- patt.design(xmpl, nitems = 3, resptype="rating",
    blnIntcovs = TRUE, cov.sel="ALL")
print(head(dsgnmat))

## ILLUSTRATING THE ISSP2000 EXAMPLE
##   simplified version of the analysis as
##   given in Dittrich et.al.(2007)

data(issp2000)

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,
             family=poisson, data=design))

# 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,
             family=poisson, data=design))

## Not run: 
## example with control list
## not run because input data file does not exist

# defining the ctrl list
# would be typically read from file using source()
testex1<-list(
   resptype     = "paircomp",
   datafile     = "test/test.dat",
   nitems       = 5,
   blnRevert    = FALSE,
   blnReducecat = TRUE,
   blnIntcovs   = FALSE,
   cov.sel      = c("SEX","URB"),

   blnGLIMcmds  = TRUE,
   glimCmdFile  = "test/test.gli",
   outFile      = "test/test.design",
   intFile      = ""        # since blnIntcovs = FALSE
)
patt.design(testex1)
## End(Not run)


[Package prefmod version 0.8-13 Index]