【问题标题】:How to use the fast99 in the sensitivity package如何使用灵敏度包中的fast99
【发布时间】:2019-07-26 11:51:37
【问题描述】:

我正在尝试使用 R 对函数进行全局敏感性分析。我对 R 完全陌生,所以我很难正确理解文档。 我想使用灵敏度包中的 fast99 方法,但它会为我的 4 个因子中的 2 个返回 NaN。

我正在使用 R Studio 和灵敏度包。

我的功能是

Func<-function(
  Input
){
  alpha<-Input[,1]
  beta<-Input[,2]
  gamma<-Input[,3]
  nu<-Input[,4]
  root<-4*beta+alpha^2*gamma +2*alpha*beta*gamma*nu+beta^2*gamma*nu^2
  denominator<-2*beta*gamma
  summand<-alpha*gamma-beta*gamma*nu
  result<-(summand+sqrt(gamma)*sqrt(root))/denominator
  return(result)
}

然后我打电话

library(sensitivity)
factors<-c("alpha","beta", "gamma", "nu")
x<-fast99(Mtb, factors=factors, n=1000, q.arg=list(min=0, max=1))
print(x)

我希望每个因素的结果都是某个数字,但它会返回

Call:
fast99(model = Mtb, factors = factors, n = 1000, q.arg = list(min = 0,     max = 1))

Model runs: 4000 

Estimations of the indices:
      first order total order
alpha         NaN         NaN
beta   0.23928895   0.8855446
gamma  0.03075694   0.5991250
nu            NaN         NaN

这不可能,因为 alpha 应该很重要

我发现问题,如果我将最小值设置为 0.001,它工作正常,除以零似乎有问题,这让我很恼火,因为分母中只有 beta 和 gamma。但现在它工作正常。

【问题讨论】:

    标签: r


    【解决方案1】:

    问题在于最小值为 0

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-30
      相关资源
      最近更新 更多