fit: Fits a HMM model

Description Usage Arguments Value See Also Examples

View source: R/fit.R

Description

Fits the transition probabilities of the model by maximum likelihood. The transition probabilities are fitted by ML, subject to the linear constraints specified in the model. The argument retrain can be used to avoid local minima. It is possible to specify additional non linear constraints, passing the suitable arguments to the optimizer.

Usage

1
fit(x, e, init = FALSE, method = "solnp", retrain = 1, ...)

Arguments

x

A HMM model.

e

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

init

Logical specifying whether the initial state found in x is going to be used. Defaults to FALSE, which means that steady state initialization will be used instead.

method

The optimization algorithm to be used. Defaults to solnp from package Rsolnp. The other possible choice is constrOptim from package stats.

retrain

The times the optimizer will be launched with different initial parameters. The model with higher likelihood will be returned.

...

Arguments to be passed to the optimizer.

Value

The fitted model.

See Also

logLik, initparams, minparams

Examples

1
2
3
4
5
6
7
8
model <- HMMrectangle(20,20)
S <- function(x) if (x > 5) return(0) else return(20*log(5/x))
emissions(model) <- createEM(c(20,20), towers, S)
model <- initparams(model)
model <- minparams(model)
logLik(model,events)
model <- fit(model,events)
logLik(model,events)

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