rHMM {regmhmm}R Documentation

Fit Regularized Hidden Markov Models (rHMM) with Modified CCD

Description

Utilize the modified Cyclic Coordinate Descent (CCD) algorithm to effectively fit a regularized Hidden Markov Model (rHMM).

Usage

rHMM(
  delta,
  Y_mat,
  A,
  B,
  X_cube,
  family,
  omega_cva = sqrt(sqrt(seq(0, 1, len = 5))),
  N_iter = 1000,
  eps = 1e-07,
  trace = 0
)

Arguments

delta

a vector of length S specifying the initial probabilities.

Y_mat

a matrix of observations of size N x T.

A

a matrix of size S x S specifying the transition probabilities.

B

a matrix of size S x (p + 1) specifying the GLM parameters of the emission probabilities.

X_cube

a design array of size T x p x N.

family

the family of the response.

omega_cva

a vector of omega values for the modified cyclical coordinate descent algorithm used for cross-validation.

N_iter

the maximal number of the EM algorithm for fitting HMM.

eps

convergence tolerance.

trace

logical indicating if detailed output should be produced during the fitting process.

Value

A list object with the following slots:

delta_hat

the estimate of delta.

A_hat

the estimate of A.

B_hat

the estimate of B.

log_likelihood

the log-likelihood of the model.

lambda

lambda from CV.

omega

omega from CV.

Examples


# Example usage of the function
seed_num <- 1
p_noise <- 2
N <- 100
N_persub <- 50
parameters_setting <- list(
  init_vec = c(0.5, 0.5),
  trans_mat = matrix(c(0.7, 0.3, 0.2, 0.8), nrow = 2, byrow = TRUE),
  emis_mat = matrix(c(1, 0.5, 0.5, 2), nrow = 2, byrow = TRUE)
)
simulated_data <- simulate_HMM_data(seed_num, p_noise, N, N_persub, parameters_setting)

init_start = c(0.5, 0.5)
trans_start = matrix(c(0.5, 0.5, 0.5, 0.5), nrow = 2)
emis_start = matrix(rep(1, 8), nrow = 2)

rHMM_one_step <- rHMM(delta=as.matrix(init_start),
                               Y_mat=simulated_data$y_mat,
                               A=trans_start,
                               B=emis_start,
                               X_cube=simulated_data$X_array,
                               family="P",
                               omega_cva=sqrt(sqrt(seq(0, 1, len = 5))),
                               N_iter=10,
                               trace = 0)



[Package regmhmm version 1.0.0 Index]