| plot.ClustCpObj | R Documentation |
The plot method plots the estimates partition through the salso algorithm, for a ClustCpObj class object.
## S3 method for class 'ClustCpObj'
plot(
x,
y = NULL,
loss = "VI",
maxNClusters = 0,
nRuns = 16,
maxZealousAttempts = 10,
...
)
x |
an object of class |
y |
parameter of the generic method. |
loss |
The loss function used to estimate the final partition, it can be "VI", "binder", "omARI", "NVI", "ID", "NID". |
maxNClusters |
maximum number of clusters in salso procedure. |
nRuns |
number of runs in salso procedure. |
maxZealousAttempts |
maximum number of zealous attempts in salso procedure. |
... |
parameter of the generic method. |
The function returns a ggplot object representing the time series or the survival functions colored according to the final partition.
## Time series
data_mat <- matrix(NA, nrow = 5, ncol = 100)
data_mat[1,] <- as.numeric(c(rnorm(50,0,0.100), rnorm(50,1,0.250)))
data_mat[2,] <- as.numeric(c(rnorm(50,0,0.125), rnorm(50,1,0.225)))
data_mat[3,] <- as.numeric(c(rnorm(50,0,0.175), rnorm(50,1,0.280)))
data_mat[4,] <- as.numeric(c(rnorm(25,0,0.135), rnorm(75,1,0.225)))
data_mat[5,] <- as.numeric(c(rnorm(25,0,0.155), rnorm(75,1,0.280)))
out <- clust_cp(data = data_mat, n_iterations = 5000, n_burnin = 1000,
params = list(L = 1, B = 1000, phi = 0.5), kernel = "ts")
plot(out)
## Survival functions
data_mat <- matrix(NA, nrow = 5, ncol = 50)
betas <- list(c(rep(0.45, 25),rep(0.14,25)),
c(rep(0.55, 25),rep(0.11,25)),
c(rep(0.50, 25),rep(0.12,25)),
c(rep(0.52, 10),rep(0.15,40)),
c(rep(0.53, 10),rep(0.13,40)))
inf_times <- list()
for(i in 1:5){
inf_times[[i]] <- sim_epi_data(10000, 10, 50, betas[[i]], 1/8)
vec <- rep(0,50)
names(vec) <- as.character(1:50)
for(j in 1:50){
if(as.character(j) %in% names(table(floor(inf_times[[i]])))){
vec[j] = table(floor(inf_times[[i]]))[which(names(table(floor(inf_times[[i]]))) == j)]
}
}
data_mat[i,] <- vec
}
out <- clust_cp(data = data_mat, n_iterations = 100, n_burnin = 10,
params = list(M = 100, L = 1, B = 100), kernel = "epi")
plot(out)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.