# Mining contexts

### Description

Extracting contexts in a PST satisfying user defined criterion

### Usage

1 2 |

### Arguments

`object` |
A probabilistic suffix tree, i.e., an object of class |

`l` |
length of the context to search for. |

`pmin` |
numeric. Minimal probability for selecting the (sub)sequence. |

`pmax` |
numeric. Maximal probability for selecting the (sub)sequence. |

`state` |
character. One or several states of the alphabet for which the (cumulated) probability is greater than |

`as.tree` |
logical. If |

`delete` |
Logical. If |

### Value

If `as.tree=TRUE`

a PST, that is an object of class `PSTf`

which can be printed and plotted; if `as.tree=FALSE`

a list of contexts with their associated next symbol probability distribution, that is an object of class `cprobd.list`

for which a `plot`

method is available. Subscripts can be used to select subsets of the contexts, see examples.

### details

The `cmine`

function searches in the tree for nodes fulfilling certain characteristics, for example contexts that are highly likely to be followed by a given state (see example 1). One can also mine for contexts corresponding to a minimum or maximum probability for several states together (see example 2). For more details, see Gabadinho 2016.

### Author(s)

Alexis Gabadinho

### References

Gabadinho, A. & Ritschard, G. (2016). Analyzing State Sequences with Probabilistic Suffix Trees: The PST R Package. *Journal of Statistical Software*, **72**(3), pp. 1-39.

### Examples

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ```
## Loading the SRH.seq sequence object
data(SRH)
## Learning the model
SRH.pst <- pstree(SRH.seq, nmin=30, ymin=0.001)
## Example 1: searching for all contexts yielding a probability of the
## state G1 (very good health) of at least pmin=0.5
cm1 <- cmine(SRH.pst, pmin=0.5, state="G1")
cm1[1:10]
## Example 2: contexts associated with a high probability of
## medium or lower self rated health
cm2 <- cmine(SRH.pst, pmin=0.5, state=c("B1", "B2", "M"))
plot(cm2, tlim=0, main="(a) p(B1,B2,M)>0.5")
``` |