简体   繁体   English

在R中找到指数模型的起始参数

[英]Finding Starting Parameters in R for Exponential Models

I'm working to build some models in R and am having trouble not returning the error: 我正在努力在R中构建一些模型,并且遇到了无法返回错误的麻烦:

Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf

For reference, my dataset and the code I am trying is: 作为参考,我的数据集和正在尝试的代码是:

x <- c(1:7)
y <- c(21, 27, 26, 33, 52, 68, 96)
fit8 <- nls(y ~ a*exp(b*x), data=base, start=list(a=16, b = .22))

Where the starting values were found in Excel, but I still return the same error when using them in R. 在Excel中找到起始值的地方,但是在R中使用它们时,我仍然返回相同的错误。

In general, are there easy ways to loop through unknown starting values to avoid the error? 通常,是否有简单的方法可以循环遍历未知的起始值以避免错误? I need to create a systemic way to determine the best fit lines for ~1,000 different datasets within a larger dataset. 我需要创建一种系统的方法来确定较大数据集中约1,000个不同数据集的最佳拟合线。

When I run your code without data=base, I get the output as expected. 当我在不使用data = base的情况下运行您的代码时,将得到预期的输出。 Is it possible you have assigned other values to a data frame called base? 您是否可能已将其他值分配给了称为base的数据框?

nls(y ~ a*exp(b*x), start=list(a=16, b=.22))

It returns the output as expected: 它按预期返回输出:

Nonlinear regression model
model: y ~ a * exp(b * x)
...
  a       b 
11.8560  0.2953 
...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM