庄伟
USE R: 使用sensitivity包中的fast99命令进行局部敏感性分析
2018-9-11 17:14
阅读:7022

R中进行敏感性分析的包sensitivity中的fast的全称是Extended Fourier Amplitude Sensitivity Test。

按照R自带的HELP的描述:Description
fast99 implements the so-called "extended-FAST" method (Saltelli et al. 1999). This method allows the estimation of first order and total Sobol' indices for all the factors (alltogether 2p indices, where p is the number of factors) at a total cost of n * p simulations.


# install.packages('sensitivity')

library(sensitivity)


x <- fast99(model = ishigami.fun, factors = c('V1','V2','V3'), n = 1000,
            q = "qunif", q.arg = list(list(min = -pi, max = pi),
                                                       list(min = -2, max = 2),
                                                       list(min = -3, max = 3)))
print(x)
plot(x)


# ishigami.fun 是自带的模型,函数形式如下:

# ishigami.fun<- function (X)
#    {
#      A <- 7
#      B <- 0.1
#      sin(X[, 1]) + A * sin(X[, 2])^2 + B * X[, 3]^4 * sin(X[, 1])

# }


画图得到下图:

sa_ex.png


# 可根据自己的需要进行修改模型和参数集X,以及参数的变化区间。

library(sensitivity)


yourmodel<- function (X)
  {
    A <- 7
    B <- 0.1
    X[, 1] + A * X[, 2]^2 + B * X[, 3]^4
  }
x <- fast99(model = yourmodel, factors = c('V1','V2','V3'), n = 1000,
            q = "qunif", q.arg = list(list(min = 1, max = 10),
                                      list(min = 0, max = 10),
                                      list(min = 0, max = 10)))
print(x)
plot(x)

画图得到下图:

Rplot.png

补充:这里使用fast99进行参数的局部敏感性分析(Local sensitivity),需要将其他变量(如上面的A,B)取固定值,A,B的取值也会影响,参数的效应值大小。如果AB变化如何分析呢?需要进行的全局敏感性分析。

转载本文请联系原作者获取授权,同时请注明本文来自庄伟科学网博客。

链接地址:https://wap.sciencenet.cn/blog-526092-1134195.html?mobile=1

收藏

分享到:

当前推荐数:0
推荐到博客首页
网友评论3 条评论
确定删除指定的回复吗?
确定删除本博文吗?