subgroups: Return effects for each subgroup

View source: R/reportSensitivityAnalysis.R

subgroupsR Documentation

Return effects for each subgroup

Description

subgroups: returns the table the effects per groups. Code based on the sbgroups function written by Gilles Pujol for the function sb in the sensitivity package.

Usage

subgroups(x)

Arguments

x

data

Value

data frame with group names and effects

Examples


require("SPOT")
require("RColorBrewer")
set.seed(2)
# Interesting for larger n:
n <- 2
lower <- c(-0.1, rep(-10,n))
upper <- c(0.1, rep(10,n))

# Model-based optimization
res <- spot(,funSphere,
             lower, upper,
             control=list(funEvals=30,
                          optimizer = optimNLOPTR))

# Use the surrogate model for prediction
predictFunKriging <- function(x){
      predict(object = res$modelFit, x)
      }

# Determine sensitivity
sens <- sequentialBifurcation(predictFunKriging,
                              lower, upper,
                              k=n+1, interaction = TRUE, verbosity = 0)

# Extract group information (variable effects) from sensitivity analysis
ps <- subgroups(sens)
colors <- brewer.pal(12, "Set3")
barplot(ps$effect, names.arg=ps$group, col= colors)



SPOTMisc documentation built on Sept. 5, 2022, 5:06 p.m.