Skip to content

Commit

Permalink
fix importance pvalues for survival
Browse files Browse the repository at this point in the history
  • Loading branch information
Marvin Wright committed Jun 12, 2017
1 parent 5c30b8f commit 74d7e12
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions R/importance.R
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,14 @@ importance_pvalues <- function(x, method = c("janitza", "altmann"), num.permutat
}

## Permute and compute importance again
dependent.variable.name <- all.vars(formula)[1]
if (x$treetype == "Survival") {
dependent.variable.name <- all.vars(formula)[1:2]
} else {
dependent.variable.name <- all.vars(formula)[1]
}
vimp <- replicate(num.permutations, {
dat <- data
dat[, dependent.variable.name] <- sample(dat[, dependent.variable.name])
dat[, dependent.variable.name] <- dat[sample(nrow(dat)), dependent.variable.name]
ranger(formula, dat, num.trees = x$num.trees, mtry = x$mtry, min.node.size = x$min.node.size,
importance = x$importance.mode, ...)$variable.importance
})
Expand Down

0 comments on commit 74d7e12

Please sign in to comment.