Skip to content

Instantly share code, notes, and snippets.

@alexpghayes
Created September 16, 2025 21:32
Show Gist options
  • Select an option

  • Save alexpghayes/e7e9cc5188cc057889d818fb6bcce861 to your computer and use it in GitHub Desktop.

Select an option

Save alexpghayes/e7e9cc5188cc057889d818fb6bcce861 to your computer and use it in GitHub Desktop.
library(fastRG)
library(ggplot2)
library(vsp)
set.seed(29)
k <- 3
n <- 1000
B <- matrix(0.1, nrow = k, ncol = k)
diag(B) <- 0.8
sum(diag(B)) / (sum(B) - sum(diag(B)))
A <- dcsbm(
theta = runif(n) + 1,
k = k,
B = B,
expected_degree = 50
) |>
sample_sparse()
fa_oracle <- vsp(A, rank = k, degree_normalize = FALSE)
plot_varimax_y_pairs(fa_oracle) +
labs(
title = "Optimal/lowest entropy rotation in correct dimension",
subtitle = "Three block dc-sbm embedded into three dimensions"
)
fa_k_low <- vsp(A, rank = 2, degree_normalize = FALSE)
plot_varimax_y_pairs(fa_k_low) +
labs(
title = "Points show up 'off axes' when embedding dimension is too low",
subtitle = "Three block dc-sbm embedded into two dimensions"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment