pcpt-class: Class "pcpt"

pcpt-classR Documentation

Class "pcpt"

Description

A class for within period changepoint objects.

Objects from the Class

Objects can be created by calls of the form new("pcpt", ...).

new("pcpt", ...):

creates a new object with class pcpt

Slots

data.set:

Object of class "ts", a coerced time series of the original data.

periodlength:

Object of class "numeric", the period length of the data.

minseglen:

Object of class "numeric", the minimum segment length (no. of observations between changepoints) used in the analysis.

npcpts.max:

Object of class "numeric", maximum number of within period changepoints that can be identified.

distribution:

Object of class "character", the sampling distribution of the data being analysed.

nsegparam:

Object of class "numeric", the number of parameters for the sampling distribution per segment.

pcpt.prior:

Object of class "list", containing the within period changepoint prior details.

param.prior:

Object of class "numeric",vector containing the within period segment parameter prior details.

MCMC.options:

Object of class "list", containing algorithmic details to be supplied to the MCMC program.

MCMC.inits:

Object of class "list", containing the within period changepoint positions for initiating each chain.

MCMC.last:

Object of class "list", containing the last with period changepoint positions from each chain. Slot filled when asked to summarise chain output.

results:

Object of class "list", containing either the sampled MCMC chains (summarised slot = FALSE) or the table(s) summarising the samples (summarised slot = TRUE).

summarised:

Object of class "logical", flag indicating whether the results slot contains the summarise table of samples.

param.mode:

Object of class "matrix", most sampled within period changepoint vector from across all chains. (Nb, contains only one instance in the case of ties. See summmaised results for other modes.)

pcpt.mode:

Object of class "numeric", table containing the segment paramter mode estimates for the within period changepoint vector in the pcpt.mode slot.

fit:

Object of class "numeric", Estimates of 5 measures of fit (see fit() for further detials).

date:

Object of class "character", date and time the changepoint analysis was run.

version:

Object of class "character", version number of the package used when the analysis was run.

Methods

data.set

signature(object = "pcpt"): retrieves the data.set slot

periodlength

signature(object = "pcpt"): retrieves the periodlength slot

minseglen

signature(object = "pcpt"): retrieves the minseglen slot

npcpts.max

signature(object = "pcpt"): retrieves the npcpts.max slot

distribution

signature(object = "pcpt"): retrieves distribution slot

pcpt.prior

signature(object = "pcpt"): retrieves pcpt.prior slot

param.prior

signature(object = "pcpt"): retrieves param.prior slot

MCMC.options

signature(object = "pcpt"): retrieves MCMC.options slot

n.chains

signature(object = "pcpt"): retrieves from the MCMC.options slot the n.chains item.

n.iter

signature(object = "pcpt"): retrieves from the MCMC.options slot the n.iter item.

n.burn

signature(object = "pcpt"): retrieves from the MCMC.options slot the n.burn item.

toggle.quiet

signature(object = "pcpt"): inverts the logical item quiet in the MCMC.options slot.

MCMC.inits

signature(object = "pcpt"): retrieves MCMC.inits slot

results

signature(object = "pcpt"): retrieves results slot

result

signature(object = "pcpt", index = "numeric"): retrieves from the results slot the contents corresponding to the index-th chain.

MCMC.last

signature(object = "pcpt"): retrieves MCMC.last slot

summarised

signature(object = "pcpt"): retrieves summarised slot

summarized

signature(object = "pcpt"): retrieves summarised slot

nsegparam

signature(object = "pcpt"): retrieves nsegparam slot

pcpt.mode

signature(object = "pcpt"): retrieves pcpt.mode slot

param.mode

signature(object = "pcpt"): retrieves param.mode slot

fit

signature(object = "pcpt"): retrieves fit slot

seglen

signature(object = "pcpt"): Calculates the within period segment lengths from the pcpt.mode slot

nsegs

signature(object = "pcpt"): Calculates the number of within period segments from the pcpt.mode slot

npcpts

signature(object = "pcpt"): Calculates the number of within period changepoints from the pcpt.mode slot

print

signature(x = "pcpt"): prints details of the pcpt object including summary

show

signature(object = "pcpt"): prints details of the pcpt object including summary

summary

signature(object = "pcpt", ...): prints a summary of the pcpt object

quantile

signature(x = "pcpt", ...): quantile estimate for the segment parameters for each within period time step.

plot

signature(x = "pcpt", ...): plots the pcpt object

Author(s)

Simon Taylor Rebecca Killick

See Also

data.set-methods,PeriodCPT

Examples

showClass("pcpt") # shows the structure of the pcpt class

x = new("pcpt")       # creates a new object with the pcpt class defaults
periodlength(x)       # retrieves the periodlength slot from x
periodlength(x) <- 12 # replaces the periodlength slot from x with 12

# Example of a within period change in probability in simulated bernoulli data
set.seed(1)
x = ts(rbinom(n = 120, size = 1, rep( c(0.2,0.5), each = 6)), freq = 12)
ans = PeriodCPT(x, distribution = "bern", niter = 1e3)

print(ans) # prints details of the analysis including a summary
summary(ans)

##\/TODO\/
##########
##quantile(ans)
##plot(ans) # plots the data with change (vertical line) at 100


taylors2/PeriodCPT documentation built on June 28, 2024, 12:32 p.m.