简体   繁体   中英

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:

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.

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.

When I run your code without data=base, I get the output as expected. Is it possible you have assigned other values to a data frame called 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 
...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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