adj_matrix: Adjacency Matrix

Description Usage Arguments Details Value Warning Examples

Description

Create an adjacency matrix from two ordinal variables.

Usage

1
adj_matrix(x, y, states = NULL, direction = NULL)

Arguments

x

NumericVector.

y

NumericVector.

states

Optional integer. Specify the max number of states between the two vectors. The outputed matrix will be of size states ^ 2 x states ^ 2. Default: max(a, b).

direction

Optional string. Specify "up" to create an adjacency matrix from only increasing transitions, or "down" for decreasing transitions.

Details

The adjacency matrix represents paired transitions for two variables. If we consider each possible unique pair as serialized on an ordinal scale (1, 2, .., K) then the column numbers of the adjacency matrix denote the start position of the transition (the observed pair at observation i) and the row numbers denote the end position of the transition (the observed pair at observation i + 1). This can be visualized graphically with plot or as an igraph adjacency graph with igraph::graph.adjacency.

Value

A S3 matrix of class adj_mat. Can be plotted with the normal plot function.

Warning

adj_matrix assumes that the target variables are indexed at 0.

Examples

1
2
3
x <- c(1, 2, 2)
y <- c(2, 1, 2)
adj_matrix(x, y) # `states` will be set to 3

jsks/seqR documentation built on May 9, 2019, 12:48 p.m.