predict: Predictions from Non-homogeneous Hidden Markov Models

predict.nhmmR Documentation

Predictions from Non-homogeneous Hidden Markov Models

Description

This function computes the marginal forward predictions for NHMMs and MNHMMs, where the marginalization is (by default) over individuals and time points, weighted by the latent state probabilities.

Usage

## S3 method for class 'nhmm'
predict(
  object,
  newdata,
  newdata2 = NULL,
  condition = NULL,
  type = c("state", "response", "transition", "emission"),
  probs = c(0.025, 0.975),
  boot_idx = FALSE,
  ...
)

## S3 method for class 'mnhmm'
predict(
  object,
  newdata,
  newdata2 = NULL,
  condition = NULL,
  type = c("state", "response", "transition", "emission"),
  probs = c(0.025, 0.975),
  boot_idx = FALSE,
  ...
)

Arguments

object

An object of class nhmm or mnhmm.

newdata

A data frame used for computing the predictions.

newdata2

An optional data frame for predictions, in which case the estimates are differences between predictions using newdata and newdata2.

condition

An optional vector of variable names used for conditional predictions.

type

A character vector defining the marginal predictions of interest. Can be one or multiple of "state", "response", "transition", and "emission". Default is to compute all of these.

probs

A numeric vector of quantiles to compute.

boot_idx

Logical indicating whether to use bootstrap samples in marginalization when computing quantiles. Default is FALSE. Currently only used in case where condition is NULL and

...

Ignored.


seqHMM documentation built on June 8, 2025, 10:16 a.m.