gam0_fit_hmm: Fit an HMM

Description Usage Arguments Value

View source: R/gam0_fit_hmm.R

Description

This function fits data with an HMM by maximizing the likelihood estimate given initial gamma parameters.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
gam0_fit_hmm(
  x,
  design,
  num_states,
  num_variables,
  num_subjects,
  num_covariates,
  alpha0,
  theta0,
  zweight0,
  beta0,
  delta0,
  state_dep_dist_pooled = FALSE,
  iterlim = 100,
  steptol = 1e-06,
  hessian = FALSE,
  print.level = 0
)

Arguments

x

The data to be fit with an HMM in the form of a 3D array. The first index (row) corresponds to time, the second (column) to the variable number, and the third (matrix number) to the subject number.

design

A list of design matrices for each subject with each row indicating the time and each column indicating the value of the covariate.

num_states

The number of states in the desired HMM.

num_variables

The number of variables in the data.

num_subjects

The number of subjects/trials that generated the data.

num_covariates

The number of covariates in the data that the transition probability matrix depends on.

alpha0

The starting values for the means of the gamma distributed state dependent distributions of the HMM. alpha0 is a list of matrices, each matrix corresponding to a different variable in the data being fit. The columns of the matrices correspond to the state number and the rows correspond to the subject number.

theta0

The starting values for the standard deviations of the gamma distributed state dependent distributions of the HMM. theta0 is a list of matrices, each matrix corresponding to a different variable in the data being fit. The columns of the matrices correspond to the state number and the rows correspond to the subject number.

beta0

A matrix of the initial regression coefficients for the effect of the covariates on the transition probability matrices gamma.

delta0

A list with each element being the starting initial state distribution vector of the HMM for the subject corresponding to that index.

state_dep_dist_pooled

A logical variable indiacting whether the state dependent distribution parameters alpha and theta should be treated as equal for all subjects.

iterlim

A value indicating the number of iterations nlm() should run before exiting.

hessian

A logical variable indicating whether to compute the hessian at the minimum.

@param

zweight0 The starting values for the weights of the zero inflated portion of the gamma distributions. zweight0 is a list of vectors, one for each variable, and each vector element correspomnds to a different subject.

Value

A list of parameters that specify the fitted gamma HMM.


simonecollier/lizardHMM documentation built on Dec. 23, 2021, 2:24 a.m.