powered by
This function can be used to perturb a clustering vector in order to randomly associate certain individuals with another cluster.
lab_switching(Z, p_out = 0.1)
a perturbed clustering vector
a clustering vector
a probability of perturbation for the clustering
Z <- sample(1:4,100,replace=TRUE) p = 0.1 Z_pert <- lab_switching(Z,p) table("Initial clustering" = Z,"Perturbed clustering" = Z_pert)
Run the code above in your browser using DataLab