compare_matrices: Subtract matrices

Description Usage Slots Examples

View source: R/compare_matrices.R

Description

Subtract over two word-context matrices to uncover different word-use patterns.

Usage

1
compare_matrices(mat1, mat2, output = "mat")

Slots

mat1

A word-context matrix

mat2

A word-context matrix

output

A string (either "mat" or "vec".) If "mat", function will return a matrix (mat1 - mat2), made up of the shared rows and shared columns. If "vec", function will return a vector giving the Pearson correlation for each context word (row) shared by the matrices.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Get new matrix showing how Locke differs from peers.
data(locke)
data(nlaw)
data(eebo)
new_mat <- find_difference(locke, nlaw)

# For quick visualizations, create context dendrograms.
graph_context(new_mat, "property")

# For details: look at Z-scores of individual terms to see how Locke's usage differs.
sort(zscore(new_mat, "legislative"), decreasing = T)[1:10]

# Get similarity scores to see how differently each word is used.
vec = compare_matrices(locke, nlaw, output = "vec")
sort(vec)[1:50] # Display 50 least-similar words
vec["property"] # See how similar one word is to the context.

michaelgavin/empson documentation built on May 22, 2019, 9:50 p.m.