patt.design
converts (i) real paired comparison
responses, or (ii) a set of ratings (or 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.patt.design(obj, nitems = NULL, objnames = "", objcovs = NULL,
cat.scovs = NULL, num.scovs=NULL, resptype = "paircomp",
reverse = FALSE, ia = FALSE, casewise = FALSE, ...)
nitems
is not the
number of comparisons!objnames
is not specified o1
,o2
, etc.
will be used.cat.scovs = c("SEX", "WORK")
). If all covariates in the data
are catcat.scovs
for numerical (continuous) subject covariates. If
any numerical covariates are specified, casewise
is set to TRUE
."paircomp"
, "rating"
, or "ranking"
.ia = TRUE
.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
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.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
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.)patt.design
allows for different scenarios mainly concerning
ia = TRUE
.objcovs
above.llbt.design
,
pattPC.fit
, pattL.fit
, pattR.fit
# 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))
Run the code above in your browser using DataLab