View source: R/plotPhaseParameter.R
plotPhaseParameter | R Documentation |
Plot Estimates From RACVM Partition
plotPhaseParameter( variable, phaselist, cols = 1:length(phaselist), label = TRUE, ymax = 1000, ... )
variable |
one of: |
phaselist |
output of |
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 |
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
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.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.