postPairs: Calculate pairwise co-membership probability

Description Usage Arguments Value Examples

View source: R/postPairs.R

Description

Given a vector of cluster numbers and projection clustering output, postPairs calculate the posterior probability of any pair of subjects being clustered in the same group.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
postPairs(
  df_of_draws,
  x_var,
  id_var = "ID",
  dat,
  ls_idxA,
  nIter = 10,
  nDraw = 1000,
  nClusters,
  regQ = 1e-06,
  seed = 1
)

Arguments

df_of_draws

Data frame of simulated LMM output

x_var

Character vector of random effect variables

id_var

Character of id variable

dat

Longitudinal data input

ls_idxA

List of random effect indices to project on

nIter

Number of iterations used in clustering optimization

nDraw

Number of draws to sample from projection clustering output

nClusters

Vector of cluster numbers

regQ

Positive regularization value to add to the diagonal of matrix to be inverted

seed

Random seed to initialize cluster centers

Value

List of 2 items. ls_prob: pairwise probability tables corresponding to random effect projection specified in ls_idxA. Row and column index of table indicate subject ID number in dat. Only the lower triangular matrix is filled. arr_cluster: array of optimized cluster labels based on randomly drawn samples corresponding to chosen random effects.

Examples

1
2
3
4
5
6
7
8
9
data(df_of_draws)
ls_idxA <- list(
  seq(10),
  1:4,
  5:7,
  8:10
)
out_pc <- postPairs(df_of_draws, x_var=paste0("Z", 1:10), id_var="ID", dat=DATASET,
                    ls_idxA, nIter=10, nDraw=2, nClusters=4, regQ=1e-6, seed=1)

maoyinan/BayesPC documentation built on Dec. 21, 2021, 1:48 p.m.