Reputation: 15
Do you know the method to do my own plot of sensitivity analysis result using R?
For example (using fast99()
and a toy model):
> library(sensitivity)
> x <- fast99(model = ishigami.fun, factors = 3, n = 1000,
q = "qunif", q.arg = list(min = -pi, max = pi))
> print(x)
> Call:
> fast99(model = ishigami.fun, factors = 3, n = 1000, q = "qunif",
q.arg = list(min = -pi, max = pi))
> Model runs: 3000
> Estimations of the indices:
> first order total order
> X1 3.076874e-01 0.5506015
> X2 4.419659e-01 0.4697538
> X3 3.431342e-29 0.2391275
I just want to pick the data of the estimations of the indices (X1
, X2
, X3
), to put them in a matrix...
Any ideas?
Upvotes: 1
Views: 2685
Reputation: 206253
Perhaps something like this could work. First, a helper function to turn the fast99
data into a data.frame
as.data.frame.fast99 <- function(x, ...) {
if (!is.null(x$y)) {
S <- data.frame(X=colnames(x$X), x$D1/x$V, 1 - x$Dt/x$V)
colnames(S)[-1] <- c("first.order", "total.order")
S
}
}
And now we plot the data. (Here I use the ggplot
library but you could easily use others)
dd<-as.data.frame(x)
library(ggplot2)
ggplot(dd, aes(x=X)) +
geom_point(aes(y=first.order, color="first")) +
geom_point(aes(y=total.order, color="total")) +
scale_color_manual(values=c(first="red",total="blue"), name="order")
Upvotes: 2