summarizePhases: Summarize phases

View source: R/summarizePhases.R

summarizePhasesR Documentation

Summarize phases

Description

Takes a phase list and obtains a tidy table of point estimates of relevant parameters,

Usage

summarizePhases(phaselist)

Arguments

phaselist

a phase list (output of estimatePhases)

Value

table of start and end times and point estimates of relevant parameters for each phase

Examples

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

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")


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