Skip to content

Commit

Permalink
Merge pull request #24 from CharlieCarter/master
Browse files Browse the repository at this point in the history
Jackknife patch. # of do.call(rbind, jack) calls reduced to 1.
  • Loading branch information
prodriguezsosa authored Nov 17, 2023
2 parents 761237a + 93b2439 commit 921bddc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion R/conText.R
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ run_jack_ols <- function(X,Y, confidence_level = 0.95) {

# indices to separate the pseudo values for each coefficient
pseudo_indices <- lapply(1:ncol(X), function(i) seq(i,ncol(X)*ncol(Y), ncol(X)))
jack_betas <- lapply(pseudo_indices, function(i) do.call(rbind, jack)[i,]) %>% setNames(coefficient_names)
jack_betas <- lapply(pseudo_indices, function(i, jack_df) jack_df[i,], jack_df = do.call(rbind, jack)) %>% setNames(coefficient_names)
normed_jack_betas <- lapply(jack_betas, function(i) apply(i, 2, function(i) sqrt(sum(i^2)))) %>% do.call(rbind,.)
normed_betas <- apply(matrix(beta, nrow = nrow(beta)), 1, function(x) norm(matrix(x, nrow = 1), type = "f")) %>% setNames(coefficient_names)
pseudo_normed_betas <- lapply(1:nrow(Y), function(i) nrow(Y)*normed_betas - (nrow(Y)-1)*normed_jack_betas[,i]) %>% do.call(rbind,.)
Expand Down

0 comments on commit 921bddc

Please sign in to comment.