灵敏度错误:: fast99:“'什么'必须是字符串或函数”

时间:2014-03-23 19:48:36

标签: r runtime-error

我想对具有三个均匀分布参数的模型进行灵敏度分析:

install.packages("sensitivity")
library(sensitivity)
params <- c("param1","param2","param3")    
x <- fast99(model = myModel, factors = params, n = 1000, q = list("qunif","qunif","qunif"), q.arg = list(list(min=10, max=200), list(min=0.1, max=0.9), list(min=0.1, max=0.9)))

然而,这给了我以下错误:

Error in do.call(q[j], c(list(p = g), q.arg[[j]])) : 'what' must be a character string or a function

这是函数myModel

myModel <- function(X) {

#input parameters: convert from data frame to matrix.
X <- data.matrix(X)
#vector that holds the response values.
y <- vector()
#loop over the rows of X.
for (i in 1:nrow(X)) {
   #get the i-th row as parameter vector (string).  
   params <- paste(X[i,],collapse=" ")
   y[i] = shell(paste("C:\\Users\\name\\someApp.exe", params), intern = TRUE)
}
return(y)
}

我做错了什么?

注意:我已查看过这个类似的question,但没有找到解决问题的方法。

1 个答案:

答案 0 :(得分:2)

我是那个问这个问题的人,我终于找到了解决方案:
fast99要求参数q是字符串的向量。导致错误是因为我将q指定为列表。

因此导致错误:

x <- fast99( ..., q = list("qunif","qunif","qunif"), ...)

这有效:

x <- fast99( ..., q = c("qunif","qunif","qunif"), ...)