Skip to content

Commit

Permalink
update to readme, vignette, pkgdown
Browse files Browse the repository at this point in the history
  • Loading branch information
blind-contours committed Mar 29, 2024
1 parent 26b94d1 commit 0dd4af4
Show file tree
Hide file tree
Showing 13 changed files with 847 additions and 560 deletions.
6 changes: 5 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ Imports:
purrr,
polspline,
pracma,
haldensify
haldensify,
ranger,
arm,
xgboost,
nnls
Suggests:
rmarkdown,
knitr,
Expand Down
6 changes: 3 additions & 3 deletions R/IsoXshift.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ IsoXshift <- function(w,
num_cores = 2,
seed = seed,
hn_trunc_thresh = 10,
top_n = 2) {
top_n = 1) {

# coerce W to matrix and, if no names in W, assign them generically
if (!is.data.frame(w)) w <- as.data.frame(w)
Expand Down Expand Up @@ -190,7 +190,7 @@ IsoXshift <- function(w,

pie_min_effort_shift <- list()

fold_InterXshift_results <- furrr::future_map(
fold_IsoXshift_results <- furrr::future_map(
unique(data_internal$folds), function(fold_k) {
fold_intxn_results <- fold_basis_results[[fold_k]]

Expand Down Expand Up @@ -295,7 +295,7 @@ IsoXshift <- function(w,
.options = furrr::furrr_options(seed = seed, packages = "IsoXshift")
)

fold_min_shift_results <- unlist(fold_InterXshift_results, recursive = FALSE)
fold_min_shift_results <- unlist(fold_IsoXshift_results, recursive = FALSE)


pooled_synergy_shift_results <- calc_pooled_intxn_shifts(
Expand Down
6 changes: 3 additions & 3 deletions R/joint_stoch_shift_est_g_exp.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ joint_stoch_shift_est_g_exp <- function(exposures,
)

obs_pred_shifted <- g_model$predict(task_obs_shift_rep)
ratio <- obs_pred_no_shifted$likelihood / obs_pred_shifted$likelihood
ratio <- obs_pred_no_shifted / obs_pred_shifted
delta_diff <- abs(grid1 - delta)
replicated_data$delta_diff <- delta_diff
replicated_data$ratio <- ratio
Expand All @@ -125,8 +125,8 @@ joint_stoch_shift_est_g_exp <- function(exposures,

# Find the row with the minimum delta_diff within the filtered data
min_diff_row <- filtered_data[which.min(filtered_data$delta_diff), ]
min_diff_row$likelihood_shift <- obs_pred_shifted$likelihood[as.numeric(rownames(min_diff_row))]
min_diff_row$likelihood_no_shift <- obs_pred_no_shifted$likelihood
min_diff_row$likelihood_shift <- obs_pred_shifted[as.numeric(rownames(min_diff_row))]
min_diff_row$likelihood_no_shift <- obs_pred_no_shifted
min_diff_row$delta <- min_diff_row[, exposure] - obs_data[, exposure]

aggregate_results <- rbind(aggregate_results, min_diff_row)
Expand Down
6 changes: 3 additions & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ We define interaction as the counterfactual mean of the outcome under stochastic

To utilize the package, users need to provide vectors for exposures, covariates, and outcomes. They also specify the target_outcome_lvl for the outcome, epsilon, which is some allowed closeness to the target. For example, if the target outcome level is 15, and epsilon is 0.5, then interventions that lead to 15.5 are considered. The restriction limit is hn_trunc_thresh which is the allowed distance from the original exposure likelihood. 10 for example indicates that the likelihood should not be more than x10 difference from the original exposure level likelihood. That is, if an individual's likelihood is originally 0.1 given their covariate history and the likelihood of exposure to the intervened level is 0.01, this is 10 times different and would be the limit intervention. A detailed guide is provided in the vignette. With these inputs, `IsoXshift` processes the data and delivers tables showcasing fold-specific results and aggregated outcomes, allowing users to glean insights effectively.

`IsoXshift` also incorporates features from the `sl3` package [@coyle-sl3-rpkg], facilitating ensemble machine learning in the estimation process. If the user does not specify any stack parameters, `InterXshift` will automatically create an ensemble of machine learning algorithms that strike a balance between flexibility and computational efficiency.
`IsoXshift` also incorporates features from the `sl3` package [@coyle-sl3-rpkg], facilitating ensemble machine learning in the estimation process. If the user does not specify any stack parameters, `IsoXshift` will automatically create an ensemble of machine learning algorithms that strike a balance between flexibility and computational efficiency.


---
Expand Down Expand Up @@ -123,11 +123,11 @@ sim_results <- IsoXshift(
w = w,
a = a,
y = y,
n_folds = 5,
n_folds = 6,
num_cores = 6,
outcome_type = "continuous",
seed = seed,
target_outcome_lvl = 15,
target_outcome_lvl = 12,
epsilon = 0.5
)
proc.time() - ptm
Expand Down
Loading

0 comments on commit 0dd4af4

Please sign in to comment.