MM:

  1)  nls() doesn't suffer from this problem
  2)  There's no bug in terms() according to Brian

  ---> rnls() should try not to use  terms(...)


-----------------------------------------------------------

From: Martin Maechler <maechler@stat.math.ethz.ch>
To: "Ruckstuhl Andreas \(rks\)" <rks@zhwin.ch>
Cc: <martin.maechler@stat.math.ethz.ch>
Subject: Re: Sfsmisc: Nonlinear formula and terms()
Date: Mon, 8 Aug 2005 16:19:19 +0200

Hoi Andreas,
ich bin leider etwas im Stress

Ich denke ist eine Art bug in terms.formula() ---> gehe dem nach


Als Workaround fr Dein Problem kannst Du natrlich

    p10 <- function(x) 10^x

und dann "p10(.)" statt "10^(.)" verwenden.

Mit liebem Gruss: Martin

>>>>> "Ruckstuhl" == Ruckstuhl Andreas \(rks\) <Ruckstuhl>
>>>>>     on Mon, 8 Aug 2005 15:26:04 +0200 writes:

    Ruckstuhl> Lieber Martin Ich bin wieder mal an einer
    Ruckstuhl> robusten Anpassung eines nichtlinearen
    Ruckstuhl> Regressionsmodell. Dazu verwende ich Christian's
    Ruckstuhl> R-Version von rnls (in Eurem neusten
    Ruckstuhl> sfsmisc-package). Darin ergibt sich folgendes
    Ruckstuhl> Problem mit "10^" in der Formel (Das Bsp im Help
    Ruckstuhl> ist mit exp!):

    >> version
    Ruckstuhl> platform i386-pc-mingw32 arch i386 os mingw32
    Ruckstuhl> system i386, mingw32 status major 2 minor 1.1
    Ruckstuhl> year 2005 month 06 day 20 language R

    >> The formula, I want to use, is x1 <- ~ y -
    >> ((th2*10^(th3+th4*x))/(1+10^(th3+th4*x))) terms(x1)
    Ruckstuhl> Error in terms.formula(x1) : invalid power in
    Ruckstuhl> formula

    Ruckstuhl> However, when I replace "10^" by exp it works
    Ruckstuhl> correcly:
    >> x2 <- ~ y - ((th2*exp(th3+th4*x))/(1+exp(th3+th4*x)))
    >> terms(x2)
    Ruckstuhl> ~y - ((th2 * exp(th3 + th4 * x))/(1 + exp(th3 +
    Ruckstuhl> th4 * x))) attr(,"variables") list(y, exp(th3 +
    Ruckstuhl> th4 * x), th2) attr(,"factors") y y 1 exp(th3 +
    Ruckstuhl> th4 * x) 0 th2 0 attr(,"term.labels") [1] "y"
    Ruckstuhl> attr(,"order") [1] 1 attr(,"intercept") [1] 0
    Ruckstuhl> attr(,"response") [1] 0 attr(,".Environment")
    Ruckstuhl> <environment: R_GlobalEnv>


    Ruckstuhl> Wo ist das Problem? In terms? Oder muss der Code
    Ruckstuhl> in rnls abgendert werden, weil das so nicht
    Ruckstuhl> geht?

    Ruckstuhl> Jetzt schon herzlichen Dank fr Deine Hilfe

    Ruckstuhl> Gruss Andreas

From: Prof Brian Ripley <ripley@stats.ox.ac.uk>
To: Martin Maechler <maechler@stat.math.ethz.ch>
Cc: R-core@stat.math.ethz.ch
Subject: Re: terms.formula() not liking "10^"  ?
Date: Mon, 8 Aug 2005 15:45:38 +0100 (BST)

Since x^10 gets interpreted, why do you expect 10^x to be treated
literally?

It does not work in S either.  You do need to protect operators in formula
if you want their arithmetic meaning: if you want something analogous to
exp(x-a) then I(10^(x-a)) is needed.


On Mon, 8 Aug 2005, Martin Maechler wrote:

> Someone found a problem in some R code we've provided locally.
>
> The problem can be traced to the fact that
>
>> terms(~y - C/(1 + 10^(x - a)))
> Error in terms.formula(~y - C/(1 + 10^(x - a))) :
>        invalid power in formula
>
> whereas
>
>> terms(~y - C/(1 + exp(x - a)))
>
> works nicely.
>
> I don't have time right now to delve into this, but this looks
> like something that should be improved..
> yes?

--
Brian D. Ripley,                  ripley@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

_______________________________________________
R-core list: https://stat.ethz.ch/mailman/listinfo/r-core

