get_cpt_neighbors: Estimate the number of similar subjects

View source: R/get_cpt_neighbors.R

get_cpt_neighborsR Documentation

Estimate the number of similar subjects

Description

Estimate the number of similar subjects using univariate multiple change point detection (i.e., binary segmentation in the changepoint package).

Usage

get_cpt_neighbors(.distance_matrix)

Arguments

.distance_matrix

Matrix: a symmetric n x n matrix of distance values.

Value

Vector of positive integers: a vector of positive integers where the (i)th integer corresponds to the number of subjects (observations) that are similar to the (i)th subject.

Examples

# Import the tip library
library(tip)

# Choose an arbitrary random seed
set.seed(007)

# Generate some data (i.e., 20 subjects described by a 5 x 1 vector)
X <- matrix(rnorm(10*10),nrow=20,ncol=5)

# Compute the pairwise distances between the subjects
distance_matrix <- data.matrix(dist(X))

# For each subject, find the estimate for the number of similar subjects
get_cpt_neighbors(.distance_matrix = distance_matrix)

tip documentation built on Nov. 15, 2022, 1:05 a.m.