# [R] problem with nls()

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Nov 28 14:18:08 CET 2003

```On Fri, 28 Nov 2003, Siegfried.Macho wrote:

> I wanted to use the nls() module to solve a Problem from Sen & Srivastava
> (1990, p.209). Here is the (basic) code used to perform the estimation:
>
> library(SenSrivastava)
> library(nls)
> data(E9.8)
>
> # Use Linear Least Square for estimating start values
> lm.obj <- lm(R.1 ~ I.1 + S.1, data = E9.8)

Those are not the column names in E9.8!

> nls1.obj <- nls(R.1 ~ b.0 + b.1*(I.1^a.1-1)/a.1 + b.2*(S.1^a.2-1)/a.2,
>                          data = E9.8,
>                          start = list(b.0 = coef(lm.obj)[1], b.1 =
> coef(lm.obj)[2], b.2 = coef(lm.obj)[3],                       a.1 = 1, a.2 = 1)
>                     )
>
> unfortunately, I receive the following message from nls(): "Error in
> object[[i]] : object is not subsettable"
>
> Why do I get this message, what does it mean, and how can I avoid it ?
> Note 1: Enclosing expressions by using the function I() does not help either.
> Note 2: To avoid confusion I have changed the names I, R, S to I.1, R.1, S.1.

Perhaps that is your problem, as without changing the names this works for
me in R 1.8.1.

If you still have a problem using the actual names and R 1.8.1, please
try using R's debugging facilities to find the problem on your computer.

--
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

```