picard: Simultaneous Segmentation - Clustering of Signals using the...

Description Usage Arguments Details Value Author(s) References Examples

View source: R/picard.R

Description

These functions allow to perform a segmentation and clustering of a time series using the hybrid algorithm of Picard (2006). The function picard implements this approach either from a series of observation or from an animal trajectory. The function plot can then be used to plot the results.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
picard(x, ...)
## Default S3 method:
picard(x, P, Kmax, pos=NULL, ...)

## S3 method for class 'ltraj'
picard(x, P, Kmax, which=c("x","y"), ...)

## S3 method for class 'picard'
print(x, ...)

## S3 method for class 'picard'
plot(x, axes = FALSE, number = NULL,
                      addparam = FALSE, bg = TRUE, ...)

Arguments

x

for picard.default, a matrix with two columns containing the successive observations building up the bivariate series (the two columns are the two variables). For picard.ltraj, an object of class ltraj. For plot, an object of class "picard".

P

an integer value indicating the number of classes used for the segmentation.

Kmax

an integer value indicating the maximum number of segments expected in the series.

pos

optionnally, a vector containing the same number of elements as x, corresponding to the "coordinates" of each observation in the series (e.g. the dates corresponding to each observation).

which

a character vector of length 2 indicating which variables of the object ltraj are to be used in the segmentation process (these variables may be selected in the infolocs component of the object).

axes

a logical value indicating whether the x and y axes are to be plotted.

number

optionally, an integer value indicating which of the two variable is to be plotted (by default, both variables are stored).

addparam

a logical value indicating whether the parameters (mean and sd) should be plotted.

bg

a logical value indicating whether colored rectangle indicating the model corresponding to each segment should be drawn in the background

...

additional arguments to be passed from or to other functions

Details

The method of Picard (2006)... to be continued.

Value

The function picard returns a list containing the following elements:

Linc

a vector containing the log-likelihood for the best segmentation of the signal with K-segment

param

a list containing the parameters of the segmentation with one element per value of K; each element is itself a list containing: (i) a list named phi containing the parameters of the models, i.e. with a component named mu containing the mean of each variable (column) for each model (row), a component named sigma containing the standard deviation of each variable (column) for each model (row) and a component named prop containing the proportion of observations generated by each model; (ii) a matrix named rupt containing the indices of the limits (start, end) of the K segments (one per row); (iii) a matrix named tau containing the likelihood of each model (row) for each segment (column)

Author(s)

Clement Calenge clement.calenge@oncfs.gouv.fr Marie-Pierre Etienne marie.etienne@agroparistech.fr Emilie Lebarbier emilie.lebarbier@agroparistech.fr

References

Picard, F. 2006. Process segmentation/clustering. Application to the analysis of CGH microarray data. PhD thesis, University Paris XI, Orsay.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
############################################
##
## Example 1:

set.seed(879)

## Generates a series with 3 segments
x1 <- c(rnorm(30, 3, 1), rnorm(20, 8, 1), rnorm(10, 3, 1))
x2 <- c(rnorm(30, -2, 2), rnorm(20, 5, 2), rnorm(10, -2, 2))
xk <- cbind(x1,x2)

## fits the segmentation:
seg <- picard(xk, 2, Kmax = 5)

## Plot the result:

## the models
plot(seg)

## show the parameters for the first variable
plot(seg, number = 1, bg = FALSE, addparam = TRUE)

## show the parameters for the first variable
plot(seg, number = 2, bg = FALSE, addparam = TRUE)

############################################
##
## Example 2: no clear sequence

set.seed(980)
x <- cbind(rnorm(50), rnorm(50))

seg2 <- picard(x, 3, 8)

## Les segments sont definis par deux obs a chaque fois
## bizarre, non?
plot(seg2)

## Au passage
## Les resultats sont identiques quand on utilise
## hybrid_simultanee:
oo <- hybrid_simultanee(t(x), 3, 8)

## Je retrouve la meme chose avec des vrais trajets

############################################
##
## Example 3: wild boar

data(puechcirc)
pu <- puechcirc[1]

seg3 <- picard(pu, 2, 7)

plot(seg3)

## bizarre, non?

MarieEtienne/segTraj documentation built on May 7, 2019, 2:51 p.m.