if (FALSE) {
## 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')
}
if (FALSE) {
## 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))
}
Run the code above in your browser using DataLab