Learn R Programming

clickstream (version 1.0)

fitMarkovChain: Fits a list of click streams to a Markov chain

Description

This function fits a list of click streams 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 programming problem: $$\min w$$ $$\mathrm{s.t.}$$ $$w \ge X-[QX]\lambda$$ $$w \ge -X+[QX]\lambda$$ $$w \ge 0$$ $$\sum_{i=1}^k \lambda_i = 1$$ $$\lambda_i \ge 0$$

Usage

fitMarkovChain(clickstreamList, order = 1)

Arguments

clickstreamList
A list of click streams for which a Markov chain is fitted.
order
(Optional) The order of the Markov chain that is fitted from the click streams. 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.

Value

  • Returns a MarkovChain object.

Details

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

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

Run this code
# 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")
csf<-tempfile()
writeLines(clickstreams, csf)
cls<-readClickstreams(csf, header=TRUE)
mc<-fitMarkovChain(cls)
print(mc)

Run the code above in your browser using DataLab