plotPhaseParameter: Plot Estimates From RACVM Partition

View source: R/plotPhaseParameter.R

plotPhaseParameterR Documentation

Plot Estimates From RACVM Partition

Description

Plot Estimates From RACVM Partition

Usage

plotPhaseParameter(
  variable,
  phaselist,
  cols = 1:length(phaselist),
  label = TRUE,
  ymax = 1000,
  ...
)

Arguments

variable

one of: omega, mu.x, mu.y, eta, tau

phaselist

output of estimatePhases, i.e. a list of information on each of the selected phases

cols

colors of bars (by default - a rich color palette)

label

whether to label the plotted parameter (with the word "tau", "eta", etc.)

ymax

maximum y

...

additional arguments to pass to plotting function. A useful one is log = "y" for highly skewed data.

Details

getVariable takes a partitionlist and generates a table indicating the start time, end time, estimate, low and high 95% C.I. and selected model for a given parameter.

plotVariable

Value

getVariable returns a data.frame with start time, end time, estimate, low and high 95% C.I. and selected model for a given parameter, with each row corresponding to an enumerated partition phase.

Examples

library(smoove)
library(magrittr)
data(simSweep, package="smoove")

layout(c(1,1,1,2:6))
simCP.table <- simSweep %>%
  findCandidateChangePoints(clusterwidth = 4, verbose = FALSE) %>%
  getCPtable(modelset = c("UCVM", "ACVM"), criterion = "AIC")

simPhaselist <- estimatePhases(simCP.table)
Z <- attributes(simPhaselist)$Z
T <- attributes(simPhaselist)$time

if (!requireNamespace('gplots', quietly = TRUE))
 warning("package \"gplots\" is needed for this example. 
 Please install it first and then run this example",
        call. = FALSE)

cols <- gplots::rich.colors(length(simPhaselist))
T.cuts <- c(T[1], simCP.table$CP, T[length(T)])
Z.cols <- cols[cut(T, T.cuts, include.lowest = TRUE)]

phaseTable <- summarizePhases(simPhaselist)
plot(Z, asp=1, type="l", xpd=FALSE)
points(Z, col=Z.cols, pch=21, bg = scales::alpha(Z.cols, 0.5), cex=0.8)
legend("top", legend = paste0(phaseTable$phase, ": ", phaseTable$model),
       fill=cols, ncol=3, bty="n", title = "Phase: model")

par(mar=c(2,2,1,0), xpd=NA)
plotPhaseParameter("tau", simPhaselist, ylab="", xaxt="n", xlab="", col=cols, log="y")
plotPhaseParameter("eta", simPhaselist, ylab="", xaxt="n", xlab="", col=cols)
plotPhaseParameter("mu.x", simPhaselist, ylab= "", xaxt="n", xlab="", col=cols)
plotPhaseParameter("mu.y", simPhaselist, ylab= "", xaxt="n", xlab="", col=cols)
plotPhaseParameter("rms", simPhaselist, ylab= "", xlab="time", col=cols)


EliGurarie/smoove documentation built on Aug. 2, 2022, 10:26 p.m.