PAaSO/2 Longterm/varsellcm-clustering.R

33 lines
757 B
R
Raw Normal View History

2026-08-19 09:27:27 +02:00
ds <- readr::read_csv("2 Longterm/assigndata.csv", na = c("", "NA"))
library(VarSelLCM)
# Please indicate the number of cores you wan to use for parallelization
nb.CPU <- 4
# clustering without variable selection (about than 10/20 sec on 4 CPU)
clusters <- ds |> select(!mrs_1) |> na.omit() |>
mutate(across(is.character, ~ factor(.x))) |> as.data.frame() |>
VarSelCluster(
gvals = 1:5,
crit.varsel = "BIC",
vbleSelec = FALSE,
nbcores = nb.CPU
)
summary(clusters)
plot(clusters)
plot(x=clusters, y="mdi_1")
plot(x=clusters, y="sex")
print(clusters)
coef(clusters)
VarSelShiny(clusters)
clusters@partitions@zMAP
gtsummary::tbl_summary(tibble(ds |> na.omit(), class=clusters@partitions@zMAP),by=class) |> gtsummary::add_p()