Adds a new engine to the lagdynamics registry so it can be referenced by
name via lsa(..., engine = "<name>"). Built-in engines
("classical", "two_cell", "bidirectional",
"parallel_dominance", "nonparallel_dominance") are registered
automatically when the package loads.
Usage
register_lsa_engine(name, fn, description, requires = character())Arguments
- name
Character scalar. The engine's identifier as used in
lsa(engine = name).- fn
A function. Must accept a
transitionsargument (a tidy transition table produced bylsa_transitions()) and arbitrary named...arguments forwarded fromlsa(params = list(...)). Must return a named list with at least the matrix elementsobs,exp,prob,adj_res, andp(eachK x K). AdditionalK x Kmatrices are preserved as engine-specific edge statistics.- description
Character scalar. One-line human-readable description shown by
list_lsa_engines().- requires
Character vector. Names of packages the engine depends on. Empty by default.
Examples
my_engine <- function(transitions, ...) {
get_lsa_engine("classical")$fn(transitions, ...)
}
register_lsa_engine("my_classical", my_engine, "Classical test alias")
fit <- lsa(engagement, engine = "my_classical")
unregister_lsa_engine("my_classical")
fit
#> Lag Sequential Analysis - my_classical (lag 1, directed)
#> 3 states | 1734 transitions | 1870 events | 136 sequences
#> states: Active, Average, Disengaged
#> independence: G² = 618.3, df = 4, p <2e-16
#>
#> Significant transitions (p < 0.05): 7 of 9
#> strongest over-represented (of 3):
#> Active -> Active z = +21.7 ***
#> Disengaged -> Disengaged z = +15.4 ***
#> Average -> Average z = +12.5 ***
#>
#> Initial states:
#> Active 0.382 ████████████████████████
#> Average 0.368 ███████████████████████
#> Disengaged 0.250 ████████████████