Description Usage Arguments Value Examples
adjust cluster ids by specification
1 | fix_cluster(cluster_list, z, N, t, mylist)
|
cluster_list |
a list of clusters, each comprised of subject ids known to fall in the same cluster. |
z, N, t, mylist |
cluster ids for all subjects, cluster sizes, total # clusters, unique cluster ids (includes 0). |
z,N,t,mylist,c_next
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | # simulate data:
L0 <- 100 # dimension of measurements.
M0 <- 3 # true dimension of latent states.
K0 <- 2^M0 # true number of clusters.
options_sim0 <- list(N = 100, # sample size.
M = M0, # true number of machines.
L = L0, # number of antibody landmarks.
K = K0, # number of true components.
theta = rep(0.8,L0), # true positive rates.
psi = rep(0.15,L0), # false positive rates.
#alpha1 = 1, # half of the people have the first machine.
frac = 0.2, # fraction of positive dimensions (L-2M) in Q.
#pop_frac = rep(1/K0,K0) # population prevalences.
#pop_frac = (1:K0)/sum(1:K0) # population prevalences.
pop_frac = c(rep(2,4),rep(1,4)) # population prevalences.
#pop_frac = c(rep(0.75/4,4),rep(0.25/4,4))
)
simu <- simulate_data(options_sim0, SETSEED=TRUE)
dat <- simu$datmat
t_max <- 40
n <- options_sim0$N
hc <- hclust(dist(dat),"complete")
t <- floor(t_max/4)
z <- cutree(hc,k = t)
mylist <- rep(0,t_max+3); mylist[1:t] <- 1:t # mylist[1:t] is the list of active cluster IDs.
c_next <- t+1
N <- rep(0,t_max+3); N[1:t] <- table(z)
log_p <- rep(0,n+1)
zs <- z
S <- rep(0,n)
# before forcing clusters:
list(z=z,N=N,t=t,mylist=mylist,c_next=c_next)
cl_list <- list(c(1:(rle(simu$Z)$lengths[1])),
c((1+rle(simu$Z)$lengths[1]):(rle(simu$Z)$lengths[2])))
cl_list
fix_cluster(cl_list,z,N,t,mylist)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.