Skip to contents

Extract beta and gamma matrices from tmfast objects

Usage

# S3 method for tmfast
tidy(
  x,
  k,
  matrix = "beta",
  df = TRUE,
  exponent = NULL,
  keep_original = FALSE,
  rotation = NULL
)

Arguments

x

tmfast object

k

Index (number of topics/factors)

matrix

Desired matrix, either word-topic (beta) or topic-doc distributions (gamma)

df

Return a long dataframe (default) or wide matrix?

exponent

Renormalize the probabilities using a given exponent Applies only for df == TRUE

keep_original

If renormalizing, return original (pre-renormalized) probabilities?

rotation

Optional rotation matrix; see details

Value

A long dataframe, with one row per word-topic or topic-doc combination. Column names depend on the value of matrix.

Details

If rotation is not NULL, loadings/scores will be rotated. This might be used to align the fitted topics with known true topics, as in the journal_specific simulation. Loadings are left-multiplied by the given rotation, while scores are right-multiplied by the transpose of the given rotation.