fix style
This commit is contained in:
parent
eb093605b3
commit
b445c1033f
1 changed files with 7 additions and 7 deletions
|
|
@ -40,11 +40,11 @@
|
||||||
library(tidyverse)
|
library(tidyverse)
|
||||||
library(FactoMineR)
|
library(FactoMineR)
|
||||||
|
|
||||||
# 00-Load ----------------------------------------------------------------------
|
# 00 - Load --------------------------------------------------------------------
|
||||||
m_sample <- read_rds("data/processed/m_sample.rds")
|
m_sample <- read_rds("data/processed/m_sample.rds")
|
||||||
all_vars <- setdiff(names(m_sample), c("code", "municipality"))
|
all_vars <- setdiff(names(m_sample), c("code", "municipality"))
|
||||||
|
|
||||||
# 01-Exclude genuinely uninformative variables ---------------------------------
|
# 01 - Exclude genuinely uninformative variables -------------------------------
|
||||||
# Removed from every part of the analysis: redundant totals, geographic areas,
|
# Removed from every part of the analysis: redundant totals, geographic areas,
|
||||||
# and always-zero columns that add no discriminating information.
|
# and always-zero columns that add no discriminating information.
|
||||||
truly_exclude <- c(
|
truly_exclude <- c(
|
||||||
|
|
@ -70,7 +70,7 @@ truly_exclude <- c(
|
||||||
|
|
||||||
analysis_vars <- setdiff(all_vars, truly_exclude)
|
analysis_vars <- setdiff(all_vars, truly_exclude)
|
||||||
|
|
||||||
# 02-Define variable roles -----------------------------------------------------
|
# 02 - Define variable roles ---------------------------------------------------
|
||||||
|
|
||||||
# (a) Educational provision: the research object → col.sup
|
# (a) Educational provision: the research object → col.sup
|
||||||
col_sup_edu <- analysis_vars[
|
col_sup_edu <- analysis_vars[
|
||||||
|
|
@ -142,7 +142,7 @@ active_vars <- analysis_vars[
|
||||||
# Everything else → post-hoc correlations with CA dimensions
|
# Everything else → post-hoc correlations with CA dimensions
|
||||||
outside_ca <- setdiff(analysis_vars, c(active_vars, col_sup_vars))
|
outside_ca <- setdiff(analysis_vars, c(active_vars, col_sup_vars))
|
||||||
|
|
||||||
# 03-Build CA matrix -----------------------------------------------------------
|
# 03 - Build CA matrix ---------------------------------------------------------
|
||||||
X <- m_sample |>
|
X <- m_sample |>
|
||||||
select(all_of(c(active_vars, col_sup_vars))) |>
|
select(all_of(c(active_vars, col_sup_vars))) |>
|
||||||
as.data.frame()
|
as.data.frame()
|
||||||
|
|
@ -156,7 +156,7 @@ if (na_count > 0) {
|
||||||
|
|
||||||
idx_sup <- seq(length(active_vars) + 1L, ncol(X))
|
idx_sup <- seq(length(active_vars) + 1L, ncol(X))
|
||||||
|
|
||||||
# 04-Run CA --------------------------------------------------------------------
|
# 04 - Run CA ------------------------------------------------------------------
|
||||||
ca <- CA(X, ncp = 10, col.sup = idx_sup, graph = FALSE)
|
ca <- CA(X, ncp = 10, col.sup = idx_sup, graph = FALSE)
|
||||||
|
|
||||||
contribs <- ca$col$contrib |>
|
contribs <- ca$col$contrib |>
|
||||||
|
|
@ -169,7 +169,7 @@ for (d in paste0("Dim ", 1:5)) {
|
||||||
cat(paste0(" ", top5), sep = "\n")
|
cat(paste0(" ", top5), sep = "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
# 05-Post-hoc: correlate row scores with outside-CA variables ------------------
|
# 05 - Post-hoc: correlate row scores with outside-CA variables ----------------
|
||||||
ca_row_coords <- as.data.frame(ca$row$coord)
|
ca_row_coords <- as.data.frame(ca$row$coord)
|
||||||
|
|
||||||
outside_data <- m_sample |>
|
outside_data <- m_sample |>
|
||||||
|
|
@ -187,7 +187,7 @@ posthoc_cor <- cor(
|
||||||
as.data.frame() |>
|
as.data.frame() |>
|
||||||
rownames_to_column("dimension")
|
rownames_to_column("dimension")
|
||||||
|
|
||||||
# 06-Save ----------------------------------------------------------------------
|
# 06 - Save --------------------------------------------------------------------
|
||||||
write_rds(ca, "data/processed/ca_exploratory.rds")
|
write_rds(ca, "data/processed/ca_exploratory.rds")
|
||||||
write_rds(
|
write_rds(
|
||||||
list(
|
list(
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue