hzTransitionProbabilities {aqp} R Documentation

## Horizon Transition Probabilities

### Description

Functions for creating and working with horizon (sequence) transition probability matrices.

### Usage

```hzTransitionProbabilities(x, name, loopTerminalStates = FALSE)
```

### Arguments

 `x` A `SoilProfileCollection` object. `name` A horizon level attribute in `x` that names horizons. `loopTerminalStates` should terminal states loop back to themselves? This is useful when the transition probability matrix will be used to initialize a `markovchain` object. See examples below.

### Details

See the following tutorials for some ideas:

horizon designation TP

http://ncss-tech.github.io/AQP/aqp/hz-transition-probabilities.html

soil color TP

http://ncss-tech.github.io/AQP/aqp/series-color-TP-graph.html

### Value

The function `hzTransitionProbabilities` returns a square matrix of transition probabilities. See examples.

The function `genhzTableToAdjMat` returns a square adjacency matrix. See examples.

The function `mostLikelyHzSequence` returns the most likely sequence of horizons, given a `markovchain` object initialized from horizon transition probabilities and an initial state, `t0`. See examples.

### Note

These functions are still experimental and subject to change.

### Author(s)

D.E. Beaudette

`generalize.hz`

### Examples

```
data(sp4)
depths(sp4) <- id ~ top + bottom

# horizon transition probabilities: row -> col transitions
(tp <- hzTransitionProbabilities(sp4, 'name'))

## Not run:
## plot TP matrix with functions from sharpshootR package
library(sharpshootR)
par(mar=c(0,0,0,0), mfcol=c(1,2))
plot(sp4)
plotSoilRelationGraph(tp, graph.mode = 'directed', edge.arrow.size=0.5)

data(loafercreek, package='soilDB')

# convert contingency table -> adj matrix / TP matrix
tab <- table(loafercreek\$hzname, loafercreek\$genhz)

# plot
par(mar=c(0,0,0,0), mfcol=c(1,1))
plotSoilRelationGraph(m, graph.mode = 'directed', edge.arrow.size=0.5)

## demonstrate markovchain integration
library(markovchain)
tp.loops <- hzTransitionProbabilities(sp4, 'name', loopTerminalStates = TRUE)

# init new markovchain from TP matrix
mc <- new("markovchain", states=dimnames(tp.loops)[], transitionMatrix = tp.loops)

# simple plot
plot(mc, edge.arrow.size=0.5)

# check absorbing states
absorbingStates(mc)