zhuangwei的个人博客分享 http://blog.sciencenet.cn/u/zhuangwei

博文

USE R: 使用sensitivity包中的fast99命令进行局部敏感性分析

已有 6789 次阅读 2018-9-11 17:14 |个人分类:R|系统分类:科研笔记

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://blog.sciencenet.cn/blog-526092-1134195.html

上一篇:USE R: 画出温度、降雨决定的Whittaker生物群系biome
下一篇:ifort:在windows10的linux子系统中安装intel parallel studio用于fortran编译
收藏 IP: 124.115.59.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (3 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-26 01:00

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部