pattR.fit {prefmod}R Documentation

Function to fit a pattern model for (partial) rankings

Description

Function to fit a pattern model for (partial) rankings (transformed to paired comparisons) allowing for missing values using a CL approach.

Usage

pattR.fit(obj, nitems, formel = ~1, elim = ~1, resptype = "ranking",
    ia = 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
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 "ranking" by default and is reserved for future usage. Any other specification will not change the behaviour of pattR.fit
ia interaction parameters between comparisons that have one object in common if ia = TRUE.
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

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. See also formula.

The spcification 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).

Value

On return the function provides a list with elements

result a list of results from the fitting routine (see Value of nlm.
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.

Input Data

The responses have to be coded as consecutive integers starting with 1. The value of 1 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. Missing values are coded as NA, ties are not allowed (in that case use pattL.fit. Rows with less than 2 ranked objects 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. 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).

For an example without covariates and no mising values see salad or the file salad.dat in the package's data/ directory.

Warning

The size of the table to be analysed increases dramatically with the number of items . For rankings the number of paired comparison response categories is always two. The number of rows of the table used to set up the design matrix is factorial(number of items). For instance, for nine objects this is 362880. A reasonale maximum number of items is 8.

The option NItest = TRUE has to be used with care. The meaning of missing responses is not obvious with partial rankings. Are the corresponding values really missing or just not chosen.

Author(s)

Reinhold Hatzinger

See Also

patt.design, pattL.fit, pattPC.fit

Examples

## fit of Critchlov & Fligner (1991) Salad Dressings Data

data(salad)
pattR.fit(salad, nitems=4)

# alternatively use glm() with patt.design()

sal<-patt.design(salad,nitems=4,resptype="ranking")
glm(y~A+B+C+D,family=poisson,data=sal)

[Package prefmod version 0.8-13 Index]