Skip to content

Commit 1626219

Browse files
Copilotkaiemjoy
andauthored
Polish cluster variance naming
Co-authored-by: kaiemjoy <16113030+kaiemjoy@users.noreply.github.com>
1 parent 59c7203 commit 1626219

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

R/compute_cluster_robust_var.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@
2121
pop_data_combined <- do.call(rbind, pop_data_list)
2222
standard_var_log_lambda <- 1 / fit$hessian |> as.numeric()
2323

24-
subset_cluster_vars <- unlist(
24+
cluster_var_combinations <- unlist(
2525
lapply(seq_along(cluster_var), function(n_vars) {
2626
utils::combn(cluster_var, n_vars, simplify = FALSE)
2727
}),
2828
recursive = FALSE
2929
)
3030

31-
cluster_var_terms <- vapply(subset_cluster_vars, length, integer(1))
31+
n_vars_per_subset <- vapply(cluster_var_combinations, length, integer(1))
3232
robust_var_log_lambda <- 0
3333

34-
for (i in seq_along(subset_cluster_vars)) {
35-
cluster_vars_subset <- subset_cluster_vars[[i]]
34+
for (i in seq_along(cluster_var_combinations)) {
35+
cluster_vars_subset <- cluster_var_combinations[[i]]
3636
if (length(cluster_vars_subset) == 1) {
3737
cluster_ids <- pop_data_combined[[cluster_vars_subset]]
3838
} else {
@@ -49,7 +49,7 @@
4949
pop_data_combined = pop_data_combined
5050
)
5151
robust_var_log_lambda <- robust_var_log_lambda +
52-
(-1)^(cluster_var_terms[[i]] + 1) * subset_var_log_lambda
52+
(-1)^(n_vars_per_subset[[i]] + 1) * subset_var_log_lambda
5353
}
5454

5555
# Use a conservative floor so cluster-robust variance does not fall below the

0 commit comments

Comments
 (0)