khetmeans: K-Means Clustering for Heteroscedastic Extremes

Description Usage Arguments Details Value Author(s) References Examples

View source: R/khetmeans.R

Description

This function performs k-means clustering for heteroscedastic extremes.

Usage

1
  khetmeans(y, centers, iter.max = 10, alpha = 0.5)

Arguments

y

data frame from which the estimate is to be computed; first column corresponds to time and the second to the remainder of interest.

centers

the number of clusters or a set of initial (distinct) cluster centres. If a number, a random set of (distinct) rows in y is chosen as the initial centers.

iter.max

the maximum number of iterations allowed. The default is 10.

alpha

the tuning parameter. The default is 0.5.

Details

The intermediate sequence κ_T is chosen proportional to T/\log T.

Value

khetmeans returns an object of class "khetmeans" which has a fitted method. It is a list with at least the following components:

mus.new

cluster center scedasis density.

mugamma.new

cluster center extreme value index.

clusters

cluster allocation.

Y

raw data.

n.clust

number of clusters.

The plot method depicts the k-means clustering for heteroscedastic extremes. If c.c is TRUE, the method displays the cluster means.

Author(s)

Miguel de Carvalho, Rodrigo Rubio.

References

Rubio, R., de Carvalho, M. and Huser, R. (2018) Similarity-Based Clustering of Extreme Losses from the London Stock Exchange. Submitted.

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
## Not run: 
## Example 1  (Scenario B, T = 5000)
## This example requires package evd 
require(evd)
set.seed(12)
T <- 5000
n <- 30
b <- 0.1
gamma1 <- 0.7
gamma2 <- 1
grid <- seq(0, 1, length = 100)
c2 <- function(s)
    dbeta(s, 2, 5)
c3 <- function(s)
    dbeta(s, 5, 2)
X <- matrix(0, ncol = T, nrow = n)
for(i in 1:5)
  for(j in 1:T)
    X[i,  j] <- rgev(1, c2(j / T), c2(j / T), gamma1)
for(i in 6:15)
  for(j in 1:T)
    X[i,  j] <- rgev(1, c2(j / T), c2(j / T), gamma2)
for(i in 16:20)
  for(j in 1:T)
    X[i,  j] <- rgev(1, c3(j / T), c3(j / T), gamma1)
for(i in 21:30)
  for(j in 1:T)
    X[i,  j] <- rgev(1, c3(j / T), c3(j / T), gamma2)
Y <- t(X)
fit <- khetmeans(Y, centers = 4)
plot(fit, c.c = TRUE)
lines(grid, c2(grid), type = 'l', lwd = 8, col = 'black')
lines(grid, c3(grid), type = 'l', lwd = 8, col = 'black')

## End(Not run)

## Not run: 
## Example 2 (Overlapping version of Fig. 5 in Supplementary Materials)
data(lse)
attach(lse)
y <- -apply(log(lse[, -1]), 2, diff)
fit <- khetmeans(y, centers = 3)
plot(fit, c.c = TRUE, ylim = c(0, 3))

## End(Not run)

extremis documentation built on Nov. 27, 2020, 9:07 a.m.

Related to khetmeans in extremis...