sstates: Smooth states

Description Usage Arguments Value See Also Examples

View source: R/sstates.R

Description

Returns the smooth states from the forward-backward algorithm.

Smooth states are the marginal of the state conditional on the observations, for each time. This agrees with the so called γ from the Baum-Welch algorithm.

It is returned as a matrix, so that the smooth state for time instant i is the column i of the matrix.

Usage

1
2
3
4
sstates(...)

## S3 method for class 'HMM'
sstates(x, e)

Arguments

x

A HMM model.

e

A vector with the observed events. It admits missing values.

Value

A sparse matrix. The number of rows is the number of states, and the number of columns is the number of observed events. Each column of the output matrix corresponds to the probability mass function for the state, so it sums up to one.

See Also

HMM, scpstates, backward

Examples

1
2
3
4
5
6
7
8
9
model <- HMMrectangle(10,10)
tws <- matrix(c(3.2, 6.1, 2.2, 5.7, 5.9, 9.3, 5.4,
4.0, 2.9, 8.6, 6.9, 6.2, 9.7, 1.3),
nrow = 2, ncol = 7)
S <- function(x) if (x > 5) return(0) else return(20*log(5/x))
emissions(model)<-createEM(c(10,10), tws, S)
obs <- c(1,2,NA,NA,NA,NA,7,7)
model <- fit(model, obs)
sstates(model, obs)

MobilePhoneESSnetBigData/destim documentation built on Dec. 7, 2020, 7:35 p.m.