pattLrep.fit {prefmod} | R Documentation |
Function to fit a pattern model for repeated ratings/Likert items (transformed to paired comparisons) allowing for missing values using a CL approach.
pattLrep.fit(obj, nitems, tpoints = 1, formel = ~1, elim = ~1, resptype = "ratingT", undec = FALSE, ia = FALSE, iaT = FALSE, NItest = FALSE, pr.it = FALSE)
obj |
either a dataframe or the path/name of the datafile to be read. |
nitems |
the number of items at one time point. |
tpoints |
the number of time points. |
formel |
the formula for subject covariates to fit different preference scales for the objects (see below). |
elim |
the formula for the subject covariates that specify the table
to be analysed. If ommitted and formel is not ~1 then
elim will be set to the highest interaction between all terms
contained in formel . If elim is specified, the terms
must be separated by the * operator. |
resptype |
is "rating" by default and is reserved for future usage.
Any other specification will not change the behaviour of pattL.fit
|
undec |
for paired comparisons with a undecided/neutral category,
a common parameter will be estimated if undec = TRUE . |
ia |
for each time point interaction parameters between comparisons that have one object
in common if ia = TRUE .
|
iaT |
if ia = TRUE , dependence parameters for each item between
two successive time points. |
NItest |
separate estimation of object parameters for complete and
incomplete patterns if NItest = TRUE . Currently,
NItest is set to FALSE if subject covariates are specified.
|
pr.it |
a dot is printed at each iteration cycle if set to TRUE
|
Models including categorical subject covariates can be fitted using the
formel
and elim
arguments. formel
specifies the
actual model to be fitted. For instance, if specified as
formel=~SEX
different preference scale for the objects will be
estimated for males and females. For two or more covariates,
the operators +
or *
can be used to model main or interaction
effects, respectively. The operator :
is not allowed (redundant terms
are removed automatically). See also formula
.
The specification for elim
follows the same rules as for
formel
. However, elim
specifies the basic contingency
table to be set up but does not specify any covariates to be fitted.
This is done using formel
.
If, e.g., elim=SEX
but formel=~1
,
then the table is set up as if SEX
would be fitted but only one global
preference scale is computed. This feature
allows for the succesive fitting of nested models to enable the use of
deviance differences for model selection (see example below).
On return the function provides a list with elements (use str(return object)
for a detailed display)
|
main results of the fit like estimates, log likelihood, the call |
result |
a list of results from the fitting routine (see Value of
nlm .
|
envList |
a list with further fit details like subject covariates
design structure covdesmat , paired comparison reponse pattern matrix
Y , etc. |
partsList |
a list of the basic data structures for each subgroup
defined by crossing all covariate levels and different missing value
patterns. Each element of partsList is again a list containing
counts, missing value pattern, the CL matrix represented as a vector, and
the specification of the covariates. Use str to inspect
the elements and see example below.
|
The input data must have the following order (from left to right): all items
at first time point, all items at second time point (with the same order as before),
etc. for the other time points, optional subject covariates.
The responses have to be coded as consecutive integers starting with 1 (or 0).
The value of 1 (0) means highest ‘endorsement’ (agreement)
according to the underlying scale.
Missing values are coded as NA
,
rows with less than 2 valid responses are removed from the fit
and a message is printed.
Optional subject covariates have to be specified such that the categories are represented by consecutive integers starting with 1. Rows with missing values for subject covariates are removed from the data and a message is printed. Again, the leftmost columns in the data must be the ratings, optionally followed by columns for categorical subject covariates.
The data specified via obj
are supplied using either a data frame
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)
.
For an example see issp2000
or the file issp2000.dat
in
the package's data/
directory.
The size of the table to be analysed increases dramatically with the number of items and time points. For ratings (Likert items) the number of paired comparison response categories is always three. For each time point the number of rows of the table to set up the design matrix is initially (2 * number of categories - 1) ^ (number of items). After reducing to three categories the number of patterns are 13, 75, 541 for 3 to 5 items. Generally, the number of rows in the design matrix is (number of patterns ^ (number of timepoints)) * number of (combined covariate levels. A (reasobale) maximum number of items for two time points is 5, for three timepoints 4, and for four to five timepoints 3.
Reinhold Hatzinger
pattL.fit
,patt.design
, pattPC.fit
, pattR.fit
## simulated data: 3 items, 2 timepoints dat<-as.data.frame(matrix(sample(1:5,300,replace=TRUE),nc=6)) res<-pattLrep.fit(dat, nitems=3, tpoints=2, iaT=TRUE) res patt.worth(res,obj.names=LETTERS[1:2])