accessors_carp: Get Clustering Results for 'CARP'

Description Usage Arguments Details Examples

Description

get_cluster_labels returns a factor vector of cluster labels. get_clustered_data returns a matrix (with the same dimensions and names as the original data), but with the values for each observation replaced by its "estimated" value (i.e., the appropriate cluster centroid). get_cluster_centroids returns a k-by-p matrix of cluster centroids, with the same column names as the original data.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
get_cluster_labels(x, ...)

## S3 method for class 'CARP'
get_cluster_labels(x, ..., percent, k)

get_cluster_centroids(x, ...)

## S3 method for class 'CARP'
get_cluster_centroids(x, ..., percent, k, refit = TRUE)

get_clustered_data(x, ...)

## S3 method for class 'CARP'
get_clustered_data(x, ..., percent, k, refit = TRUE)

Arguments

x

An object of class CARP as produced by CARP

...

Additional arguments - if any are provided, an error is signalled.

percent

A number between 0 and 1, giving the regularization level (as a fraction of the final regularization level used) at which to get cluster labels.

k

The desired number of clusters. If no iteration with exactly this many clusters is found, the first iterate with fewer than k clusters is used.

refit

Should "naive" centroids (TRUE) or the actual centroids estimated by convex clustering be used? The default (refit = TRUE) centroids returned are actual centroids (mean) of all elements assigned to that cluster; if refit = FALSE, the \hat{U} from the convex clustering problem is used. Due to the global shrinkage imposed, these clusters are more "shrunk together" than the naive clusters.

Details

get_clustered_data and get_cluster_centroids return centroids on the original scale of the data, independent of any pre-processing flags passed to CARP. Note that exactly one of percent and k must be supplied to each function.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
carp_fit <- CARP(presidential_speech)

# Get clustering results from 50% along the path
get_cluster_labels(carp_fit, percent = 0.5)

# Get labels corresponding to the 3 cluster solution
get_cluster_labels(carp_fit, k = 3)

# Get 3 cluster centroids
get_cluster_centroids(carp_fit, k = 3)

# Get the clustered estimates for k = 3 clusters
get_clustered_data(carp_fit, k = 3)

jjn13/clustRviz documentation built on Sept. 1, 2020, 7:53 a.m.