Learn R Programming

SPOT (version 2.4.2)

subgroups: 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 groupnames and effects

Examples

Run this code
# NOT RUN {
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 <- RColorBrewer::brewer.pal(12, "Set3") 
barplot(ps$effect, names.arg=ps$group, col= colors) 
# }
# NOT RUN {
        
# }

Run the code above in your browser using DataLab