诸位高手:
俺遇到一个头疼的问题。有一个函数y=f(x; a, b, c),其中y是因变量,x是自变量,a、b、c是待拟合参数。
因为这个模型的形式十分复杂,所以我没有使用nlim函数去拟合。假设我选取的a、b、c参数的初始值合适(即初始值能够产生可以合理的拟合值),有一组实验得到的数据,使用f(x; a, b, c)去拟合。具体过程是使用最优化函数optim,看Chi-Square是否最小,Chi-Square就是设定的收敛指标。
具体举出一个logistic模型(y=c/(1+exp(a-b*x)))的例子(尽管这个模型可以使用其它软件比如matlab来拟合)的拟合:
x <- c(15.2, 18.2, 23, 25.5, 29.1)
D <- c(39.2, 20.4, 10.6, 7.6, 6.4)
y <- 1/D
# convergence function
Control <- function(q){
c <- q[1]
a <- q[2]
b <- q[3]
expected <- c/(1+exp(a-b*x))
# to calculate Chi-square
abs(sum((y-expected)^2/expected))
}
# optimization
Result <- optim(c(0.19, 0.01, 0.2), Control)
# To obtain the fitted model parameters, namely goalc, goala, goalb.
goalc <- Result$par[1]
goala <- Result$par[2]
goalb <- Result$par[3]
其中a的初值为0.01,b的初值为0.2,c的初值为0.19。这些初值的设定都是执行optim所必须的。
随后写了篇稿子投到美国,结果审稿人提出了如下的疑问,我不知道是什么意思,也不知道如何回答,请多赐教。
Let me state my question once again: “Why and how the model fitting renders a chi-square (χ2) value (in particular, when the algorithms (SSI-P and OptimSSI-P) were taken)?” By this, I mean: when a random variable (X) is distributed as a standard normal distribution, then we know that X2 has a χ2 distribution with 1 degree of freedom (df). The sum of several independent χ2 distribution is still a chi-square with its df equals to the sum of individual dfs of each χ2-variates. Statistical (regression) models with summary χ2-test or χ2-criterion are based on this property even a large-sample approximation is used. This is so crucial that, without validating the chi-square framework, all subsequent inferences are not reliable. The authors should explain why your model produces χ2-values.