Last data update: 2014.03.03

R: Draw latent scale diagram
draw.latentR Documentation

Draw latent scale diagram

Description

Writes a file of commands for the dot program to draw a graph proposed by Rosenbaum (1987) and useful for checking for non-intersecting item characteristic curves which are a property of various sorts of latent scale including Guttman, Rasch and the Mokken double monotone scale.

Usage

draw.latent(mat, rootname = NULL, threshold = 0, which.npos = NULL,
   labels = NULL, reorder = TRUE)
## S3 method for class 'draw.latent'
print(x, ...)
## S3 method for class 'draw.latent'
plot(x, graphtype = "png", ...)

Arguments

mat

A matrix or data.frame of binary item responses

rootname

The commands will be written to rootname.dt. If NULL they will be written to the standard output

threshold

Patterns are only printed if more frequent than threshold, defaults to 0 meaning all those which actually occur are printed

which.npos

Which values of number of items positive to print, NULL means all and is the default. Duplicates are removed

labels

Labels for subgraphs, NULL means none, a character vector supplies the labels, otherwise labelled as n positive

reorder

logical, put the items in ascending order of prevalence, defaults to TRUE

x

An object of class draw.latent

graphtype

Character: one of the graph types supported by dot

...

Other arguments

Details

The plot method actually does the plotting and invisibly returns the result of the system command which executes dot. The output file will be named with the rootname followed by the graph type (after a dot). The print method prints some details. The routine does not draw the graph itself but leaves that to the dot program from graphviz which you need to install.

More extensive documentation is provided in the documentation directory.

Value

Outputs the commands to draw the patterns and in addition returns:

rootname

the rootname for the command file

which.npos

which values of items positive were printed. Differs from input parameter if for some there were no valid patterns to print or duplicates have been removed

new.order

order of original items from left to right in displayed diagram. If new.order==TRUE new.order[i] is the index in the original dataset of the $i$th item in increasing prevalence

Author(s)

Michael Dewey

References

P R Rosenbaum. Probability inqualities for latent scales. British Journal of Mathematical and Statistical Psychology, 40: 157–168, 1987

Examples

set.seed(20150114)
mat <- cbind(
   sample(0:1, 100, prob = c(0.2, 0.8), replace = TRUE),
   sample(0:1, 100, prob = c(0.4, 0.6), replace = TRUE),
   sample(0:1, 100, prob = c(0.5, 0.5), replace = TRUE),
   sample(0:1, 100, prob = c(0.6, 0.4), replace = TRUE),
   sample(0:1, 100, prob = c(0.8, 0.2), replace = TRUE)
)
res <- draw.latent(mat, rootname = "mat")
#
# now need to plot(res, graphtype = "png")
#

Results