Package MmgraphR. R topics documented: September 14, Type Package

Similar documents
Package ECctmc. May 1, 2018

Package pomdp. January 3, 2019

Package cattonum. R topics documented: May 2, Type Package Version Title Encode Categorical Features

Package Mondrian. R topics documented: March 4, Type Package

Package iterators. December 12, 2017

Package fastdummies. January 8, 2018

Package longclust. March 18, 2018

Package JBTools. R topics documented: June 2, 2015

Package PCADSC. April 19, 2017

Package datasets.load

Package collapsibletree

Package cgh. R topics documented: February 19, 2015

Package areaplot. October 18, 2017

Package pairsd3. R topics documented: August 29, Title D3 Scatterplot Matrices Version 0.1.0

Package svd. R topics documented: September 26, 2017

Package raker. October 10, 2017

Package imgur. R topics documented: December 20, Type Package. Title Share plots using the imgur.com image hosting service. Version 0.1.

Package filematrix. R topics documented: February 27, Type Package

Package spark. July 21, 2017

Package canvasxpress

Package docxtools. July 6, 2018

Package dyncorr. R topics documented: December 10, Title Dynamic Correlation Package Version Date

Package desplot. R topics documented: April 3, 2018

Package jdx. R topics documented: January 9, Type Package Title 'Java' Data Exchange for 'R' and 'rjava'

Package gridgraphics

Package ConvergenceClubs

Package bisect. April 16, 2018

Package slam. February 15, 2013

Package Rglpk. May 18, 2017

Package rmatio. July 28, 2017

Package sfc. August 29, 2016

Package basictrendline

Package kirby21.base

Package clustering.sc.dp

Package mixphm. July 23, 2015

Package CatEncoders. March 8, 2017

Package lhs. R topics documented: January 4, 2018

Package crochet. January 8, 2018

Package nmslibr. April 14, 2018

Package sure. September 19, 2017

Package d3plus. September 25, 2017

Package MIICD. May 27, 2017

Package weco. May 4, 2018

Package gridgraphviz

Package scatterd3. March 10, 2018

Package manet. September 19, 2017

Package gppm. July 5, 2018

Package lpsymphony. February 6, 2018

Package mixexp. February 15, 2013

Package geogrid. August 19, 2018

Package effectr. January 17, 2018

Package ipft. January 4, 2018

Package gggenes. R topics documented: November 7, Title Draw Gene Arrow Maps in 'ggplot2' Version 0.3.2

Package projector. February 27, 2018

Continuous-time stochastic simulation of epidemics in R

Package elmnnrcpp. July 21, 2018

Package clipr. June 23, 2018

Package EnQuireR. R topics documented: February 19, Type Package Title A package dedicated to questionnaires Version 0.

Package tropicalsparse

Package validara. October 19, 2017

Package CuCubes. December 9, 2016

Package nprotreg. October 14, 2018

Package esabcv. May 29, 2015

Package gibbs.met. February 19, 2015

Package d3heatmap. February 1, 2018

Package waterfall. R topics documented: February 15, Type Package. Version Date Title Waterfall Charts in R

Package ClustGeo. R topics documented: July 14, Type Package

Package vip. June 15, 2018

Package RCA. R topics documented: February 29, 2016

Package harrypotter. September 3, 2018

Package DCD. September 12, 2017

Package panelview. April 24, 2018

Package slam. December 1, 2016

Package rxylib. December 20, 2017

Package slickr. March 6, 2018

Package qicharts2. March 3, 2018

Package binarylogic. December 13, 2017

Package comphclust. May 4, 2017

Package MatrixCorrelation

Package hyphenatr. August 29, 2016

Package truncreg. R topics documented: August 3, 2016

Package Combine. R topics documented: September 4, Type Package Title Game-Theoretic Probability Combination Version 1.

Package ptinpoly. February 20, 2015

Package pwrab. R topics documented: June 6, Type Package Title Power Analysis for AB Testing Version 0.1.0

Package gems. March 26, 2017

Package future.apply

Package distrteach. R topics documented: January 20, Version 2.3 Date

Package ASICS. January 23, 2018

Package EvolutionaryGames

Package gtrendsr. August 4, 2018

Package vesselr. R topics documented: April 3, Type Package

Package pwrrasch. R topics documented: September 28, Type Package

Package Numero. November 24, 2018

Package jstree. October 24, 2017

Package MixSim. April 29, 2017

Package autoshiny. June 25, 2018

Package regexselect. R topics documented: September 22, Version Date Title Regular Expressions in 'shiny' Select Lists

Package oec. R topics documented: May 11, Type Package

Package fst. December 18, 2017

Package ecoseries. R topics documented: September 27, 2017

Transcription:

Type Package Package MmgraphR September 14, 2018 Title Graphing for Markov, Hidden Markov, and Mixture Transition Distribution Models Version 0.3-1 Date 2018-08-23 Maintainer Pauline Adamopoulou <padamopo@gmail.com> Description Produces parallel coordinate plots of probability transition matrices from Markov, hidden Markov, and mixture transition distribution models. URL https://r-forge.r-project.org/scm/viewvc.php/pkg/mmgraphr/?root=traminer Depends R(>= 3.1.1), TraMineR, colorspace Imports march, msm License GPL (>= 2) LazyData true Author Pauline Adamopoulou [aut, cre, cph], Gilbert Ritschard [ths], Andre Berchtold [ths], Reto Buergin [ctb], Ogier Maitre [ctb] Repository CRAN Repository/R-Forge/Project traminer Repository/R-Forge/Revision 980 Repository/R-Forge/DateTimeStamp 2018-08-23 09:07:58 Date/Publication 2018-09-14 14:30:06 UTC NeedsCompilation no R topics documented: MmgraphR-package.................................... 2 march.dcmm.trmatplot................................... 4 trmat............................................. 6 trmatplot........................................... 7 1

2 MmgraphR-package Index 12 MmgraphR-package Graphing for Markov, Hidden Markov, and Mixture Transition Distribution Models Description MmgraphR produces parallel coordinate plots which map each element in a probability transition matrix (of any order) as a line. Each line is weighted by probability, and so the thicker the line, the more probable a sequence of states is and vice-versa. Probability transition matrices reflecting higher order dependencies, often useful in life-course studies, can also be mapped. Additional functionalities of MmgraphR include probability filters that can easily be applied to emphasize the most (or least) probable state sequences overall, or by initial state. Any specific element(s) of the probability transition matrix can also be highlighted. To render the plot more attractive, various color palettes using the Hue-Chroma-Luminance color scheme have been builtin and can be easily selected by the user. The package is available through CRAN as well as R-forge, where it is developed. Although MmgraphR can be used on its own, it is also compatible with the output of R packages msm, HiddenMarkov, HMM, depmixs4, seqhmm, as well as march. Details Package: MmgraphR Version: 0.3-1 Date: 2018-08-23 Depends: R (>= 3.1.1), TraMineR, colorspace Imports: march, msm License: GPL (>= 2) LazyData: true URL: https://cran.r-project.org/package=mmgraphr URL: https://r-forge.r-project.org/scm/viewvc.php/pkg/mmgraphr/?root=traminer Encoding: latin1 Author(s) Pauline Adamopoulou [aut, cre, cph], Andre Berchtold [ths], Gilbert Ritschard [ths], Reto Buergin [cbt], Ogier Maitre [cbt], Maintainer: Pauline Adamopoulou <padamopo@gmail.com> References Buergin, R. and G. Ritschard (2014), "A decorated parallel coordinate plot for categorical longitudinal data", The American Statistician. Vol. 68(2), pp. 98-103.

MmgraphR-package 3 Zeileis, A.; Hornik, K. and P. Murrell (2009), "Escaping RGBland: Selecting Colors for Statistical Graphics", Computational Statistics & Data Analysis. Vol. 53, pp. 3259-3270. See Also trmatplot, trmatplot.default, trmatplot.array, trmatplot.depmix.fitted, trmatplot.dthmm, trmatplot.hmm, trmatplot.msm, march.dcmm.trmatplot Examples ## Plotting a probability transition matrix ########################################### trmat<-matrix(c(0.1, 0.05, 0.05, 0.80, 0.06, 0.02, 0.03, 0.89, 0.03, 0.01, 0.01, 0.95, 0, 0, 0, 1), nrow = 4, ncol = 4, byrow = TRUE) trmatplot(trmat) #--- Setting a seed so that the graphic can be replicated trmatplot(trmat, seed = 2) #--- Defining a second order probability transition matrix as an array trmatarray <- array(c( 0.30, 0.70, 0.65, 0.35, 0.05, 0.95, 0.99, 0.01), dim = c( 1, 2, 4)) #--- Plotting with user-defined colors trmatplot(trmatarray, seed = 3, morder = 2, cpal = c("grey40", "grey70")) # cspal: ready-to-use color palettes using colorspace ##################################################### #--- Color palette "dynamic" trmatplot(trmat, seed = 2, cspal = "dynamic") #--- Color palette "harmonic" trmatplot(trmat, seed = 2, cspal = "harmonic") ## pfilter: Filtering out most (or least) probable sequences ############################################################ #--- The most probable sequence given a state

4 march.dcmm.trmatplot trmatplot(trmat, seed = 2, pfilter = "smax") #--- The ten least probable sequences trmatplot(trmat, seed = 2, pfilter = "tmin", num = 10 ) march.dcmm.trmatplot Transition Matrix Plot for march.dcmm objects Description Usage A coordinate plot which maps each element in the probability transition matrix (of any order) as a line, where each line is weighted by probability. Users can apply filters to emphasize the most (or least) probable state sequences overall, or by initial state. Various color palettes using the Hue- Chroma-Luminance color scheme can be easily selected by the user. Input is an object of class march.dcmm which is the output of march.dcmm.construct. ## For class 'march.dcmm' march.dcmm.trmatplot ( d, seed = NULL, type = "hidden", hstate = 1, cspal = NULL, cpal = NULL, main = NULL, xlab = NULL, ylab = NULL, ylim = NULL, xtlab = NULL, ytlab = NULL, pfilter = NULL, shade.col = "grey80", num = NULL, hide.col = NULL, lorder = NULL, plot = TRUE, verbose = FALSE,...) Arguments d seed type hstate cspal cpal main xlab ylab ylim Object to be plotted. A march.dcmm object. A single value, interpreted as an integer, or NULL (default). See Details. Character string. Can be specified as either "hidden", if the hidden matrix is to be plotted (default) or as "visible" if the visible matrix is to be plotted. Numeric. Valid when type = "visible". Specifies from which hidden state the (visible) probability transition matrix should be plotted. Default hstate = 1. A color palette that can be specified as one of: "dynamic", "harmonic", "cold", "warm", "heat", "terrain". The rainbow_hcl, heat_hcl, and terrain_hcl commands are used to generate color palettes. See Examples in trmatplot. Color palette vector when coloring probability sequences. The rainbow_hcl command is used to generate a color palette if none is specified. Title for the graphic. Default is Probability Transition Matrix. Label for the x axis. Default is Time. Label for the y axis. Default is States. Numeric vector of length 2 giving the y coordinates range.

march.dcmm.trmatplot 5 xtlab ytlab pfilter shade.col Label for the x axis ticks. Default is time (t, t+1,...). Labels for the y axis ticks. Probability filter. Can be specified as one of "tmax", "tmin", "smax", "smin". See Details. The color for sequences shaded out using the pfilter argument. Default is "grey80". See Details. num Numeric. The number of sequences to be highlighted, a whole number from 1 to length(d) - 1. Must be specified only when using pfilter="tmax" or pfilter="tmin". Default is NULL. hide.col The color for sequences shaded out using the filter argument. Default is "grey80". See Details. lorder plot verbose Line order. Either "background" or "foreground". When pfilter is used lorder is set by default. Logical. Should the object be plotted. Default is TRUE. Logical. Reports extra information on progress. Default is FALSE.... Additional arguments, such as graphical parameters, to be passed on. See par and seqpcplot. Details Setting a seed allows the graphic to be replicated. The pfilter argument serves to highlight probability sequences that are either most probable while shading out those that are less probable in shade.col and vice-versa. The four options for pfilter are described below, and are illustrated in Examples in trmatplot. "smax" For each initial state the most probable next state is highlighed. "smin" For each initial state the least probable next state is highlighed. "tmax" The sequence of states with the highest probability overall is highlighed. To highlight the n most probable sequences of states, set num = n. "tmin" The sequence of states with the lowest probability overall is highlighed. To highlight the n least probable sequences of states, set num = n. The filter and hide.col arguments are inherent in and may be passed on to seqpcplot. The filter argument serves to specify filters to gray less interesting patterns. The filtered-out patterns are displayed in the hide.col color. The filter argument expects a list with at least elements type and value. Most relevant within the context of probabilities is type = "sequence", which highlights the specific pattern. See Examples in trmatplot. Value trmatplot returns an object of class trmatplot. Some of the arguments are inherent in par and seqpcplot.

6 trmat Author(s) Pauline Adamopoulou References Buergin, R. and G. Ritschard (2014), "A decorated parallel coordinate plot for categorical longitudinal data", The American Statistician. Vol. 68(2), pp. 98-103. Zeileis, A.; Hornik, K. and P. Murrell (2009), "Escaping RGBland: Selecting Colors for Statistical Graphics", Computational Statistics & Data Analysis. Vol. 53, pp. 3259-3270. See Also trmatplot, trmatplot.default, trmatplot.depmix.fitted, trmatplot.array, seqpcplot, par. trmat Extract a Probability Transition Matrix Description Extracts a probability transition matrix. Usage ## S3 method for class 'depmix.fitted' trmat ( d ) Arguments d Object of class depmix.fitted. Details The function trmat extracts the probability transition matrix from a depmix.fitted object and returns it as a matrix. trmat is used internally by the function trmatplot.depmix.fitted in order to extract the probability transition matrix to be plotted. Value trmat returns an the probability transition matrix as an object of class matrix. Author(s) Pauline Adamopoulou

trmatplot 7 See Also trmatplot, trmatplot.depmix.fitted, depmix.fitted, trmatplot Transition Matrix Plot Description Usage A parallel coordinate plot which maps each element in the probability transition matrix (of any order) as a line, where each line is weighted by probability. Users can apply filters to emphasize the most (or least) probable state sequences overall, or by initial state. Various color palettes using the Hue-Chroma-Luminance color scheme can be easily selected by the user. Input is either an object of class matrix, array, depmix.fitted, or a list of class msm, hmm or of class dthmm. ## S3 method for classes 'matrix', 'array', ## 'depmix.fitted', 'dthmm', 'hmm', and 'msm' trmatplot ( d, seed = NULL, rowconstraint = TRUE, morder = 1, cspal = NULL, cpal = NULL, main = NULL, xlab = NULL, ylab = NULL, ylim = NULL, xtlab = NULL, ytlab = NULL, pfilter = NULL, shade.col = "grey80", num = NULL, hide.col = NULL, lorder = NULL, plot = TRUE, verbose = FALSE,...) Arguments d seed rowconstraint morder cspal cpal main xlab Object to be plotted. A transition matrix of probabilities. Can be of any order. An object of class matrix, array, depmix.fitted, dthmm, hmm, or msm. See Details. A single value, interpreted as an integer, or NULL (default). See Details. Logical. Checks if the row constraint is satisfied, i.e. the sum of each row of the transition probability matrix equals one. Default is TRUE. Numeric. The order of the probability transition matrix, d, to be plotted. Default is 1. See Details. A color palette that can be specified as one of: "dynamic", "harmonic", "cold", "warm", "heat", or "terrain". The rainbow_hcl, heat_hcl, and terrain_hcl commands are used to generate color palettes. The rainbow_hcl command is used to generate a color palette if none is specified. Color palette vector when coloring probability sequences. Cannot specify both cspal and cpal. Title for the graphic. Default is Probability Transition Matrix. Label for the x axis. Default is Time.

8 trmatplot ylab ylim xtlab ytlab pfilter shade.col Label for the y axis. Default is States. Numeric vector of length 2 giving the y coordinates range. Labels for the x axis ticks. Default is time (t, t+1,...). Labels for the y axis ticks. Probability filter. Can be specified as one of "tmax", "tmin", "smax", "smin". See Details. The color for sequences shaded out using the pfilter argument. Default is "grey80". See Details. num Numeric. The number of sequences to be highlighted, a whole number from 1 to length(d) - 1. Must be specified only when using pfilter="tmax" or pfilter="tmin". Default is NULL. hide.col The color for sequences shaded out using the filter argument. Default is "grey80". See Details. lorder plot Details verbose Line order. Either "background" or "foreground". When pfilter is used lorder is set by default. Logical. Should the object be plotted. Default is TRUE. Logical. Reports extra information on progress. Default is FALSE.... Additional arguments, such as graphical parameters, to be passed on. See par and seqpcplot. The object d to be plotted, is a probability transition matrix that can be of class matrix, array, depmix.fitted, dthmm, hmm, msm. If the probability transition matrix is the output of packages implemented using S3 methods and classes, such as msm, HiddenMarkov, HMM, or seqhmm it is a matrix which is element of a list. More specifically, using the package HMM, the function inithmm returns a list containing the element transprobs with the probability transition matrix. Within the HiddenMarkov, dthmm returns a list of class dthmm with the element Pi which is a probability transition matrix, either user-defined or estimated. Similarly, the seqhmm functions build_mm and build_hmm return a list of class hmm containing the element transition_probs with the estimated probability transition matrix. The package msm proposes the pmatrix.msm and pmatrix.piecewise.msm to extract the probability transition matrix from a fitted multi-state model (a list of class msm), as returned by msm. If the object d to be plotted is an object of msm, the function pmatrix.msm is used with the default settings to extract the probability transition matrix. In the case of depmixs4, which uses S4 classes, a probability transition matrix may be obtained depending on the type of model computed using depmix followed by fit and is embedded in an object of class depmix.fitted. Setting a seed allows the graphic to be replicated. If morder > 1, in other words, the order of the probability transition matrix d is of order greater than one, then d must be specified in reduced form. Structural zeroes are not accepted. The pfilter argument serves to highlight probability sequences that are either most probable while shading out those that are less probable in shade.col and vice-versa. The four options for pfilter are described below, and are illustrated in Examples. "smax" For each initial state the most probable next state is highlighed.

trmatplot 9 Value "smin" For each initial state the least probable next state is highlighed. "tmax" The sequence of states with the highest probability overall is highlighed. To highlight the n most probable sequences of states, set num = n. "tmin" The sequence of states with the lowest probability overall is highlighed. To highlight the n least probable sequences of states, set num = n. The filter and hide.col arguments are inherent in and may be passed on to seqpcplot. The filter argument serves to specify filters to gray less interesting patterns. The filtered-out patterns are displayed in the hide.col color. The filter argument expects a list with at least elements type and value. Most relevant within the context of probabilities is type = "sequence", which highlights the specific pattern. See Examples. trmatplot returns an object of class trmatplot. Some of the arguments are inherent in par and seqpcplot. Author(s) Pauline Adamopoulou References Buergin, R. and G. Ritschard (2014), "A decorated parallel coordinate plot for categorical longitudinal data", The American Statistician. Vol. 68(2), pp. 98-103. Zeileis, A.; Hornik, K. and P. Murrell (2009), "Escaping RGBland: Selecting Colors for Statistical Graphics", Computational Statistics & Data Analysis. Vol. 53, pp. 3259-3270. See Also seqpcplot, par. Examples ########################################## # Plotting a probability transition matrix ########################################## trmat<-matrix(c(0.1, 0.05, 0.05, 0.80, 0.06, 0.02, 0.03, 0.89, 0.03, 0.01, 0.01, 0.95, 0, 0, 0, 1), nrow = 4, ncol = 4, byrow = TRUE) trmatplot(trmat) #--- Setting a seed so that the graphic can be replicated trmatplot(trmat, seed = 2)

10 trmatplot #--- Adjusting line width trmatplot(trmat, seed = 2, lwd = 0.8) #--- Defining a second order probability transition matrix as an array trmatarray <- array(c( 0.30, 0.70, 0.65, 0.35, 0.05, 0.95, 0.99, 0.01), dim = c(1, 2, 4)) #--- Plotting with user-defined colors trmatplot(trmatarray, seed = 3, morder = 2, cpal = c("grey40", "grey70")) ########################################################### # cspal: ready-to-use color palettes using colorspace ########################################################### #--- Color palette "dynamic" trmatplot(trmat, seed = 2, cspal = "dynamic") #--- Color palette "harmonic" trmatplot(trmat, seed = 2, cspal = "harmonic") #--- Color palette "cold" trmatplot(trmat, seed = 2, cspal = "cold") #--- Color palette "warm" trmatplot(trmat, seed = 2, cspal = "warm") #--- Color palette "heat" trmatplot(trmat, seed = 2, cspal = "heat") #--- Color palette "terrain" trmatplot(trmat, seed = 2, cspal = "terrain") ########################################################### # pfilter: Filtering out most (or least) probable sequences ########################################################### #--- The most probable sequence given a state trmatplot(trmat, seed = 2, pfilter = "smax") #--- The least probable sequence given a state

trmatplot 11 trmatplot(trmat, seed = 2, pfilter = "smin") #--- The two most probable sequnces trmatplot(trmat, seed = 2, pfilter = "tmax", num = 2 ) #--- The ten least probable sequences trmatplot(trmat, seed = 2, pfilter = "tmin", num = 10 ) ###################################################### # filter: Highlighting a specific sequence of interest ###################################################### #--- Highlight the probability that a sequence is initially in state 1 and then in state 4 trmatplot(trmat, seed = 2, filter = list(type = "sequence", value = "(1)-(4)"))

Index Topic package MmgraphR-package, 2 array, 7, 8 build_hmm, 8 build_mm, 8 trmatplot.default, 3, 6 trmatplot.depmix.fitted, 3, 6, 7 trmatplot.dthmm, 3 trmatplot.hmm, 3 trmatplot.msm, 3 depmix, 8 depmix.fitted, 6 8 depmixs4, 2 dthmm, 8 fit, 8 heat_hcl, 4, 7 HiddenMarkov, 2 HMM, 2 inithmm, 8 list, 7, 8 march.dcmm.trmatplot, 3, 4 matrix, 6 8 MmgraphR (MmgraphR-package), 2 MmgraphR-package, 2 msm, 2, 7, 8 par, 5, 6, 8, 9 pmatrix.msm, 8 pmatrix.piecewise.msm, 8 rainbow_hcl, 4, 7 seqhmm, 2 seqpcplot, 5, 6, 8, 9 terrain_hcl, 4, 7 trmat, 6 trmatplot, 3 7, 7, 9 trmatplot.array, 3, 6 12