build_mm: Build a Markov Model

Description Usage Arguments Details Value See Also Examples

View source: R/build_mm.R

Description

Function build_mm builds and automatically estimates a Markov model. It is also a shortcut for constructing a Markov model as a restricted case of an hmm object.

Usage

1
build_mm(observations)

Arguments

observations

An stslist object (see seqdef) containing the sequences.

Details

Unlike the other build functions in seqHMM, the build_mm function automatically estimates the model parameters. As initial and transition probabilities can be directly estimated from the observed initial state probabilities and transition counts, there is no need for starting values or further estimation with the fit_model function.

Value

Object of class hmm with following elements:

observations

State sequence object or a list of such containing the data.

transition_probs

A matrix of transition probabilities.

emission_probs

A matrix or a list of matrices of emission probabilities.

initial_probs

A vector of initial probabilities.

state_names

Names for hidden states.

symbol_names

Names for observed states.

channel_names

Names for channels of sequence data.

length_of_sequences

(Maximum) length of sequences.

n_sequences

Number of sequences.

n_symbols

Number of observed states (in each channel).

n_states

Number of hidden states.

n_channels

Number of channels.

See Also

plot.hmm for plotting the model.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Construct sequence data
data("mvad", package = "TraMineR")

mvad_alphabet <-
  c("employment", "FE", "HE", "joblessness", "school", "training")
mvad_labels <- c("employment", "further education", "higher education",
  "joblessness", "school", "training")
mvad_scodes <- c("EM", "FE", "HE", "JL", "SC", "TR")
mvad_seq <- seqdef(mvad, 17:86, alphabet = mvad_alphabet,
  states = mvad_scodes, labels = mvad_labels, xtstep = 6)

# Define a color palette for the sequence data
attr(mvad_seq, "cpal") <- colorpalette[[6]]

# Estimate the Markov model
mm_mvad <- build_mm(observations = mvad_seq)

seqHMM documentation built on May 10, 2018, 5:04 p.m.