fitMarkovChain {clickstream}R Documentation

Fits a List of Clickstreams to a Markov Chain

Description

This function fits a list of clickstreams to a Markov chain. Zero-order, first-order as well as higher-order Markov chains are supported. For estimating higher-order Markov chains this function solves the following linear or quadratic programming problem:

\min ||\sum_{i=1}^k X-\lambda_i Q_iX||

\mathrm{s.t.}

\sum_{i=1}^k \lambda_i = 1

\lambda_i \ge 0

The distribution of states is given as X. \lambda_i is the lag parameter for lag i and Q_i the transition matrix.

Usage

fitMarkovChain(clickstreamList, order = 1, verbose = TRUE, control = list())

Arguments

clickstreamList

A list of clickstreams for which a Markov chain is fitted.

order

(Optional) The order of the Markov chain that is fitted from the clickstreams. Per default, Markov chains with order=1 are fitted. It is also possible to fit zero-order Markov chains (order=0) and higher-order Markov chains.

verbose

(Optional) An optimal logical variable to indicate whether warnings and infos should be printed.

control

(Optional) The control list of optimization parameters. Parameter optimizer specifies the type of solver used to solve the given optimization problem. Possible values are "linear" (default) and "quadratic". Parameter use.lpSolve determines whether lpSolve or linprog is used as linear solver.

Details

For solving the quadratic programming problem of higher-order Markov chains, an augmented Lagrange multiplier method from the package Rsolnp is used.

Value

Returns a MarkovChain object.

Note

At least half of the clickstreams need to consist of as many clicks as the order of the Markov chain that should be fitted.

Author(s)

Michael Scholz michael.scholz@th-deg.de

References

This method implements the parameter estimation method presented in Ching, W.-K. et al.: Markov Chains – Models, Algorithms and Applications, 2nd edition, Springer, 2013.

See Also

MarkovChain, Rsolnp

Examples


# fitting a simple Markov chain
clickstreams <- c("User1,h,c,c,p,c,h,c,p,p,c,p,p,o",
               "User2,i,c,i,c,c,c,d",
               "User3,h,i,c,i,c,p,c,c,p,c,c,i,d",
               "User4,c,c,p,c,d",
               "User5,h,c,c,p,p,c,p,p,p,i,p,o",
               "User6,i,h,c,c,p,p,c,p,c,d")
cls <- as.clickstreams(clickstreams, header = TRUE)
mc <- fitMarkovChain(cls)
show(mc)


[Package clickstream version 1.3.3 Index]