getTMatrix: Calculates Transition Matrix

Description Usage Arguments Value Examples

View source: R/mobilityMatrixFunctions.R

Description

Returns transition matrix from two columns in dataset. Supports relative, mixed, and absolute transition matrices as well as handling an excluded value.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
getTMatrix(
  dat,
  col_x,
  col_y,
  type,
  probs = TRUE,
  num_ranks,
  exclude_value,
  bounds,
  rerank_exclude_value,
  strict = TRUE
)

Arguments

dat

a dataframe with an "id" column

col_x

a character string denoting the first column from dat to be used in the transition matrix

col_y

a character string denoting the second column from dat to be used in the transition matrix

type

a character string indicating the type of transition matrix; accepts 'relative', 'mixed', and 'absolute'

probs

logical. If TRUE, values in transition matrix are probabilities; if FALSE, values in transition matrix are counts

num_ranks

an integer specifying the number of ranks for a relative or mixed transition matrix

exclude_value

a single numeric value that is excluded in calculating the transition matrix; see the rerank_exclude_value parameter to specify how the exclude value is handled

bounds

a sequence of numeric bounds for defining absolute transition matrix ranks

rerank_exclude_value

a character string indicating how the exclude value is handled when present; accepts 'as_new_rank', 'as_existing_rank', and 'exclude'

strict

logical. If TRUE, transition matrix is calculated from the given values. If FALSE, transition matrix is calculated by jittering the values to ensure uniqueness of bounds. Only used with relative and mixed types.

Value

Returns a list with a transition matrix as a Matrix and vectors of the the x and y bounds corresponding to the ranks in the matrix

Examples

1
2
3
4
5
6
data(incomeMobility)
getTMatrix(dat = incomeMobility,
           col_x = 't0',
           col_y = 't9',
           type = 'relative',
           num_ranks = 5)

mobilityIndexR documentation built on Jan. 20, 2021, 5:09 p.m.