Skip to content

Commit

Permalink
better recs for vint
Browse files Browse the repository at this point in the history
  • Loading branch information
bcjaeger committed Jan 18, 2024
1 parent 919f655 commit cd96a86
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions vignettes/pd.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -317,22 +317,47 @@ pbc_orsf$edema_05 <- NULL

## Find interactions using PD

Random forests are good at using interactions, but less good at telling you about them. Use `orsf_vint()` to apply the method for variable interaction scoring with PD described by Greenwell et al (2018). This can take a little while if you have lots of predictors.
Random forests are good at using interactions, but less good at telling you about them. Use `orsf_vint()` to apply the method for variable interaction scoring with PD described by Greenwell et al (2018). This can take a little while if you have lots of predictors, and it seems to work best with continuous by continuous interactions. Interactions with categorical variables are sometimes over- or under- scored.

```{r}
# use just the continuous variables
preds <- names(fit_surv$get_means())
vint_scores <- orsf_vint(fit_surv, predictors = preds)
vint_scores[1:10, ]
vint_scores
```

The scores include partial dependence values that you can pull out and plot:

```{r}
# top scoring interaction
pd_top <- vint_scores$pd_values[[1]]
# center pd values so it's easier to see the interaction effect
pd_top[, mean := mean - mean[1], by = var_2_value]
ggplot(pd_top) +
aes(x = var_1_value,
y = mean,
color = factor(var_2_value),
group = factor(var_2_value)) +
geom_line() +
labs(x = "albumin",
y = "predicted mortality (centered)",
color = "protime")
```

Again we use a sanity check with `coxph` to see if these interactions are detected using a standard test:

```{r}
# test the top score (expect strong interaction)
fit_cph <- coxph(Surv(time,status) ~ albumin * protime,
data = pbc_orsf)
Expand Down

0 comments on commit cd96a86

Please sign in to comment.