compute_strain_switching_scores_of_model: *DRAFT* Computes strain switching scores for topic pairs

View source: R/compute_strain_switching_score.R

compute_strain_switching_scores_of_modelR Documentation

*DRAFT* Computes strain switching scores for topic pairs

Description

This function takes an alignment and a model identifier and returns a data.frame with the strain switching scores for each pair of topics in that model.

Usage

compute_strain_switching_scores_of_model(alignment, model, n_ancestry_levels)

Arguments

alignment

(required) an alignment object

model

(required) a character or integer specifying the model for which strain switching scores should be computed.

n_ancestry_levels

(required) an integer specifying the maximum number of levels between the target model and the model hosting the parent topic.

Details

The strain switching score for a given pair of topic (k1, k2) in model K is currently computed as follow: - the path of each topic is identified - the models K1 and K2 at which each path first appears are identified - the parent model K' is selected as the "latest" model between K1, K2 and Kmin, where Kmin is the model that is n_ancestry_level ahead of K - for each topic k' in K', the strain switching score for the triplet (k', k1, k2) is computed as r(k') w_in(k',k1) w_in(k', k2) - the topic k' which maximizes that score for the pair (k1, k2) is returned together with the score and K'.

Value

A data.frame providing the strain switching scores for each pair of topic in the target model.

Examples

library(purrr)
data <- rmultinom(10, 20, rep(0.1, 20))
lda_params <- setNames(map(1:5, ~ list(k = .)), 1:5)
lda_models <- run_lda_models(data, lda_params)

alignment <- align_topics(lda_models, method = "transport")
plot(alignment)

compute_strain_switching_scores_of_model(
   alignment,
   model = 5,
   n_ancestry_levels = 2
)


lasy/alto documentation built on June 23, 2024, 6:45 a.m.