gpt4 book ai didi

r - 敏感性::fast99: “' what' must be a character string or a function”错误

转载 作者:行者123 更新时间:2023-12-03 09:04:30 25 4
gpt4 key购买 nike

我想对具有三个均匀分布参数的模型执行敏感性分析:

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,但是没有找到解决我问题的方法。

最佳答案

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

所以这会导致错误:

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

这有效:
x <- fast99( ..., q = c("qunif","qunif","qunif"), ...)

关于r - 敏感性::fast99: “' what' must be a character string or a function”错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22596203/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com