Returns a logLik object compatible with stats::AIC(),
stats::BIC(), and the rest of the model-comparison toolchain.
If newdata is NULL, returns the in-sample log-likelihood
computed from the fitted node counts. Otherwise returns the held-out
log-likelihood scoring newdata under the fitted tree.
Usage
# S3 method for class 'transitiontrees'
logLik(object, newdata = NULL, ...)Arguments
- object
A
transitiontrees.- newdata
Optional. Sequence data in any format accepted by
context_tree().NULL(default) returns in-sample log-likelihood.- ...
Ignored.
Details
Out-of-vocabulary handling: when newdata contains a state not
in the tree's alphabet, the transition into that state is
omitted from scoring (it is not penalised), and the transition
out of it is scored against the root context (the unseen
state cannot extend a history). The reported nobs therefore
counts only the positions actually scored. perplexity(),
score_sequences(), and score_positions() inherit the
same behaviour.