Learn R Programming

latdiag (version 0.3)

draw.latent: Draw latent scale diagram

Description

Writes a file of commands for the dot program to draw a graph proposed by rosenbaum87latdiag 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, threshold = 0, which.npos = NULL,
   labels = NULL, reorder = TRUE)
# S3 method for draw.latent
print(x, rootname = NULL, ...)
# S3 method for draw.latent
plot(x, rootname = NULL, graphtype = "pdf", ...)

Arguments

mat

A matrix or data.frame of binary item responses

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

rootname

Character: the rootname of the file of dot commands

graphtype

Character: one of the graph types supported by dot

...

Other arguments

Value

Returns a list containing:

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

code

a character vector of the dot commands

Details

The draw.latent function produces the dot commands which will draw the graph.

The print method prints some details. If rootname is supplied it will be used as the rootname of the file of dot commands which will have file type .gv. If rootname is NULL (which is the default) just some details about the result are printed.

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 routine does not draw the graph itself but leaves that to the dot program from graphviz which you need to install and have on your path.

More extensive documentation is provided in the vignette.

References

rosenbaum87latdiag

Examples

Run this code
# NOT RUN {
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)
#
# now need to plot(res, rootname = "mat", graphtype = "pdf")
#
# }

Run the code above in your browser using DataLab