R/permuteRelief.R

Defines functions permuteRelief

Documented in permuteRelief

permuteRelief <-
  function(x, y, nperm = 100, ...) {
    dat <- x
    dat$y <- y
    
    obs <- attrEval(y ~ ., data = dat, ...)
    permuted <- matrix(NA, ncol = length(obs), nrow = nperm)
    colnames(permuted) <- names(obs)
    for (i in 1:nperm) {
      dat$y <- sample(y)
      permuted[i,] <- attrEval(y ~ ., data = dat, ...)
    }
    means <- colMeans(permuted)
    sds <- apply(permuted, 2, sd)
    permuted <- melt(permuted)
    names(permuted)[2] <- "Predictor"
    permuted$X1 <- NULL
    list(
      standardized = (obs - means) / sds,
      permutations = permuted,
      observed = obs,
      options = list(...)
    )
  }

Try the AppliedPredictiveModeling package in your browser

Any scripts or data that you put into this service are public.

AppliedPredictiveModeling documentation built on May 2, 2019, 9:22 a.m.