[R] nls() error
Berend Hasselman
bhh at xs4all.nl
Mon Apr 2 21:33:23 CEST 2012
On 02-04-2012, at 21:20, Jeff Breiwick wrote:
> Thanks for that. Sorry, I did forget to give some basics:
>
You should also reply to the list so that other can follow the thread.
I am also sending this the list.
> Running R-1.15.0 (x64) on Windows 7.
I assume you mean R2.15.0
>
> The data I gave I now realize were the untransformed data:
> y (tran) = y[2:8]/y[1:7] - 1 and x (tran) = y[1:7].
Are you sure that x (tran) = y[1:7]?
>
> I still get the same error though about couldn't find 'R_nls_iter'.
Try a clean environment.
I now did this:
nls.dat <- data.frame(x=y[1:7], y=y[2:8]/y[1:7])
nls(y ~ R * (1 - (x/K)^2), data = nls.dat, start = list(R = 0.3, K=1))
and got this answer
>
nls(y ~ R * (1 - (x/K)^2), data = nls.dat, start = list(R = 0.3, K=1))
Nonlinear regression model
model: y ~ R * (1 - (x/K)^2)
data: nls.dat
R K
1.363 164.616
residual sum-of-squares: 0.005536
Number of iterations to convergence: 15
Achieved convergence tolerance: 6.173e-09
I also did this (just in case; see above)
nls.dat <- data.frame(x=x[1:7], y=y[2:8]/y[1:7])
nls(y ~ R * (1 - (x/K)^2), data = nls.dat, start = list(R = 0.3, K=1))
and got this
>
nls.dat <- data.frame(x=x[1:7], y=y[2:8]/y[1:7])
>
nls(y ~ R * (1 - (x/K)^2), data = nls.dat, start = list(R = 0.3, K=1))
Nonlinear regression model
model: y ~ R * (1 - (x/K)^2)
data: nls.dat
R K
1.369 17.191
residual sum-of-squares: 0.008188
Number of iterations to convergence: 9
Achieved convergence tolerance: 7.046e-08
Berend
>
> Jeff Breiwick
>
> On Mon, Apr 2, 2012 at 12:06 PM, Berend Hasselman <bhh at xs4all.nl> wrote:
>
> On 02-04-2012, at 20:48, Jeff Breiwick wrote:
>
> > Hello,
> >
> > I am running a simple nls model (which a friend ran OK) but I get the
> > following error:
> >
> > Error in nls(y ~ R * (1 - (x/K)^2), data = nls.dat, start = list(R = 0.3, :
> > object 'R_nls_iter' not found
> >
> > Does anyone know what the 'R_nls_iter' error is?
> >
> > The data are:
> > x=1:8 ; y=c(14,19,25,34,43,56,69,76)
> > # starting values:
> > R=.3, K=94
>
> No Os, no R version, no context, no reproducible example.
>
> So I tried this:
>
> x <- 1:8
> y <- c(14,19,25,34,43,56,69,76)
> # starting values:
> R <- .3
> K <- 94
>
> nls.dat <- data.frame(x=x, y=y)
>
> nls(y ~ R * (1 - (x/K)^2), data = nls.dat, start = list(R = 0.3, K=94))
>
>
> and got this
>
> > nls(y ~ R * (1 - (x/K)^2), data = nls.dat, start = list(R = 0.3, K=94))
>
> Error in nls(y ~ R * (1 - (x/K)^2), data = nls.dat, start = list(R = 0.3, :
> RMate stopped at line 0
> singular gradient
> Execution halted
>
> Berend
>
> R2.15.0, Mac OS X 10.6.8
>
More information about the R-help
mailing list