Description Usage Arguments Details Author(s) References Examples

View source: R/plotVitpath2d.R

Plot the 2-D data, Viterbi path and the probability of each time point being in each state over time.

1 2 | ```
plotVitpath2d(object, R, Z, HMMest, len.dat=96432, varb=8780,
yearstart=2005, yearend=2012, cols=NA, cex.lab=1.5, cex.axis=1.5)
``` |

`object` |
is a list containing |

`R` |
is the observed data. |

`Z` |
is the binary data with the value 1 indicating that an event was observed and 0 otherwise. |

`HMMest` |
is a list which contains pie, gamma, sig, mu, and delta (the bivariate HMM parameter estimates). |

`len.dat` |
is the length of the data, that is, the number of time points. Default is 96432. |

`varb` |
is an integer indicating the length of data that will be ploted on each page. The default is 8780. |

`yearstart` |
is the starting year of the data used. Default is 2005. |

`yearend` |
is the end year of the data used. Default is 2012. |

`cols` |
is a vector defines the colors to be used for different states. If col=NA, then the default colors will be used. |

`cex.lab` |
specifies the size of the axis label text. |

`cex.axis` |
specifies the size of the tick label numbers/text. |

The returned object has four panels. Top two panels: Observed latitudes and longitudes with the center *\hat{μ}_i* of each state overlaid as the red lines; third panel: tracked most likely state sequence of the HMM; bottom panel: the estimated probability of the data being in each state, with blank representing the probability of being in the last state (typically the plot looks better if the last state represents the background state with the minimum proportion of tremor occurrence). Some example plots are in the supplementary file of the reference Wang et al. (2018).

Ting Wang and Jiancang Zhuang

Wang, T., Zhuang, J., Buckby, J., Obara, K. and Tsuruoka, H. (2018) Identifying the recurrence patterns of non-volcanic tremors using a 2D hidden Markov model with extra zeros. Journal of Geophysical Research, doi: 10.1029/2017JB015360.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | ```
pie <- c(0.008,0.2,0.4)
gamma <- matrix(c(0.99,0.007,0.003,
0.02,0.97,0.01,
0.04,0.01,0.95),byrow=TRUE, nrow=3)
mu <- matrix(c(35.03,137.01,
35.01,137.29,
35.15,137.39),byrow=TRUE,nrow=3)
sig <- array(NA,dim=c(2,2,3))
sig[,,1] <- matrix(c(0.005, -0.001,
-0.001,0.01),byrow=TRUE,nrow=2)
sig[,,2] <- matrix(c(0.0007,-0.0002,
-0.0002,0.0006),byrow=TRUE,nrow=2)
sig[,,3] <- matrix(c(0.002,0.0018,
0.0018,0.003),byrow=TRUE,nrow=2)
delta <- c(1,0,0)
y <- sim.hmm0norm2d(mu,sig,pie,gamma,delta, nsim=5000)
R <- y$x
Z <- y$z
HMMEST <- hmm0norm2d(R, Z, pie, gamma, mu, sig, delta)
Viterbi3 <- Viterbi.hmm0norm2d(R,Z,HMMEST)
plotVitpath2d(Viterbi3, R, Z,HMMEST,len.dat=5000,varb=5000,yearstart=2005, yearend=2005)
``` |

```
[1] "311.268628494"
[1] "321.130626166"
[1] "9.8619976713"
[1] "321.130626166"
[1] "321.739889593"
[1] "0.609263426928"
[1] "321.739889593"
[1] "321.93717594"
[1] "0.19728634716"
[1] "321.93717594"
[1] "322.012430315"
[1] "0.0752543752043"
[1] "322.012430315"
[1] "322.042317725"
[1] "0.0298874104897"
[1] "322.042317725"
[1] "322.054369466"
[1] "0.0120517409475"
[1] "322.054369466"
[1] "322.059260195"
[1] "0.00489072898057"
[1] "322.059260195"
[1] "322.061250345"
[1] "0.00199014916791"
[1] "322.061250345"
[1] "322.062061156"
[1] "0.000810811951339"
[1] "322.062061156"
[1] "322.062391671"
[1] "0.000330514180462"
[1] "322.062391671"
[1] "322.062526433"
[1] "0.000134762728351"
[1] "322.062526433"
[1] "322.062581388"
[1] "5.49543219108e-05"
[1] "322.062581388"
[1] "322.062603799"
[1] "2.2410992301e-05"
[1] "322.062603799"
[1] "322.062612938"
[1] "9.13975981121e-06"
[1] "322.062612938"
[1] "322.062616666"
[1] "3.72747297206e-06"
[1] "322.062616666"
[1] "322.062618186"
[1] "1.52015394406e-06"
[1] "322.062618186"
[1] "322.062618806"
[1] "6.20028686171e-07"
[1] 0.006970914 0.207384132 0.385974351
[,1] [,2]
[1,] 35.01910 136.9926
[2,] 35.00985 137.2891
[3,] 35.14774 137.3916
, , 1
[,1] [,2]
[1,] 0.0028517495 0.0004727174
[2,] 0.0004727174 0.0075836635
, , 2
[,1] [,2]
[1,] 0.0006148366 -0.0001553084
[2,] -0.0001553084 0.0005674649
, , 3
[,1] [,2]
[1,] 0.002521756 0.002202303
[2,] 0.002202303 0.003119493
[,1] [,2] [,3]
[1,] 0.99116048 6.729065e-03 0.002110455
[2,] 0.01715121 9.747502e-01 0.008098570
[3,] 0.06147635 2.776580e-09 0.938523651
[1] 1 0 0
Press <enter> to continue
```

HMMextra0s documentation built on Aug. 3, 2021, 9:06 a.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.