Construct a synthetic tna_mmm object that mirrors the structure a
fitted seqHMM mixed Markov model exposes to tna without depending on
seqHMM at runtime. The returned object can be passed to
group_model() (dispatching via group_model.tna_mmm) and to
mmm_stats() (dispatching via mmm_stats.tna_mmm).
Real seqHMM mhmm objects continue to dispatch via the original
*.mhmm methods.
Usage
random_tna_mmm(
n_clusters = NULL,
n_states = NULL,
states = NULL,
category = NULL,
alpha = NULL,
diag_boost = NULL,
n_sequences = NULL,
seq_length = NULL,
n_covariates = 1L,
seed = NULL
)Arguments
- n_clusters
An
integergiving the number of mixture clusters. IfNULL(the default), drawn from2:4on each call.- n_states
An
integer>= 2 giving the number of states. IfNULL(the default), a value is drawn from7:11on each call.- states
An optional
charactervector of state labels of length at leastn_states. The firstn_statesare used. IfNULL(the default), labels are taken fromcategoryor auto-picked from a built-in pool that fitsn_states.- category
An optional
characterstring naming a built-in label pool. Available pools are returned bylist_random_state_pools(). WhenNULL(the default), a pool whose size is at leastn_statesis sampled at random. Ignored whenstatesis supplied.- alpha
A positive
numericDirichlet concentration parameter. Small values (e.g.0.3) produce sparse, peaked transitions; large values (e.g.5) produce near-uniform transitions. IfNULL(the default), a value is drawn fromUniform(0.5, 1.0)on each call.- diag_boost
A non-negative
numericadded to the diagonal of the transition matrix before re-normalising rows. Larger values make states "stickier" (more self-transitions). IfNULL(the default), a value is drawn fromUniform(1.5, 3.0)on each call.- n_sequences
An
integergiving the number of sequences to simulate from the true parameters. IfNULL(the default), a value is drawn from500:800on each call.- seq_length
An
integergiving the length of each simulated sequence. IfNULL(the default), a value is drawn from6:20on each call.- n_covariates
An
integer>= 1 giving the number of regression variables (including the intercept) used to predict cluster membership. Default is 1 (intercept only). When > 1, additional rows are added to the coefficient matrix.- seed
An
integerrandom seed for reproducibility, orNULL(the default) for fresh randomness on every call.
Value
An object of class tna_mmm containing fields
observations, transition_probs, initial_probs, coefficients,
vcov, most_probable_cluster, cluster_names, state_names,
n_clusters, n_states, n_sequences, n_covariates.
Examples
model <- random_tna_mmm(seed = 1)
mmm_stats(model)
#> cluster variable estimate std_error ci_lower ci_upper z_value
#> 1 Cluster 2 (Intercept) 0.4825967 0.4679061 -0.4344823 1.399676 1.031397
#> p_value
#> 1 0.3023549
grp <- group_model(model)
