pattRrep.fit {prefmod} | R Documentation |
Function to fit a pattern model for repeated rankings)
Description
Function to fit a pattern model for repeated (partial) rankings (transformed to paired comparisons) allowing for missing values using a CL approach.
Usage
pattRrep.fit(obj, nitems, tpoints = 1, formel = ~1, elim = ~1,
resptype = "rankingT", obj.names = NULL, ia = FALSE,
iaT = FALSE, NItest = FALSE, pr.it = FALSE)
Arguments
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 (must be > 1). |
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 omitted and |
resptype |
is |
obj.names |
character vector with names for objects. |
ia |
|
iaT |
if |
NItest |
separate estimation of object parameters for complete and incomplete patterns if |
pr.it |
a dot is printed at each iteration cycle if set to |
Details
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 successive fitting of nested models to enable the use of deviance differences for model selection (see example below).
Value
pattRrep.fit
returns an object of class pattMod
.
The function print
(i.e., print.pattMod
) can be used to print the results and the function patt.worth
to produce a matrix of worth parameters.
An object of class pattMod
is a list containing the following components:
coefficients |
estimates |
ll |
log-likelihood of the model |
fl |
log-likelihood of the saturated model |
call |
function call |
result |
a list of results from the fitting routine (see Value of |
envList |
a list with further fit details like subject covariates design structure |
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 |
Input Data
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 1 valid response 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 rankings, 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)
.
Warning
The size of the table to be analysed increases dramatically with the number of items J
and time points T
.
For rankings the number of paired comparison response categories is always two.
For each time point the number of rows of the table to set up the design matrix is initially (J!
.
Thus, the number of rows in the design matrix is (J!) ^ T
.
The number of combined covariate levels and the number of missing value patterns have effects only on the run time.
A (reasonable) maximum number of items for two time points is 5 or 6, for three timepoints 4, and for four to seven timepoints 3.
Note
The number of timepoints can also be regarded as different response dimensions.
Author(s)
Reinhold Hatzinger
See Also
pattL.fit
,
patt.design
,
pattPC.fit
,
pattR.fit
,
pattLrep.fit
Examples
# simulated data: 3 items, 2 timepoints
dat1 <- simR(3, 100, c(.2, .7, .1))
dat2 <- simR(3, 100, c(.5, .4, .1))
dat <- data.frame(dat1, dat2)
res <- pattLrep.fit(dat, nitems = 3, tpoints = 2, iaT = TRUE)
res
patt.worth(res, obj.names = LETTERS[1:3])