[R] NLS plinear question

Katharine Mullen kate at few.vu.nl
Tue May 6 23:18:35 CEST 2008


recall that 0 ^{-.2} = 1/0^{.2}, and that dividing by 0 gives Inf.
so when 0 is in trl, part of your model for RT is Inf:

> trl <- 0:14
> p <- -.2
> cbind(1,trl, trl^p)
        trl
 [1,] 1   0       Inf
 [2,] 1   1 1.0000000
 [3,] 1   2 0.8705506
 [4,] 1   3 0.8027416
 [5,] 1   4 0.7578583
 [6,] 1   5 0.7247797
 [7,] 1   6 0.6988271
 [8,] 1   7 0.6776109
 [9,] 1   8 0.6597540
[10,] 1   9 0.6443940
[11,] 1  10 0.6309573
[12,] 1  11 0.6190439
[13,] 1  12 0.6083643
[14,] 1  13 0.5987029
[15,] 1  14 0.5898946


On Tue, 6 May 2008, Rick DeShon wrote:

> Hi All.
>
> I've run into a problem with the plinear algorithm in nls that is confusing
> me.
>
> Assume the following reaction time data over 15 trials for a single unit.
> Trials are coded from 0-14 so that the intercept represents reaction time in
> the first trial.
>
> trl      RT
>  0    1132.0
>  1     630.5
>  2    1371.5
>  3     704.0
>  4     488.5
>  5     575.5
>  6     613.0
>  7     824.5
>  8     509.0
>  9     791.0
> 10     492.5
> 11     515.5
> 12     467.0
> 13     556.5
> 14     456.0
>
> Now fit a power function to this data using nls with the plinear algorithm
> >fit.pw  <-nls(RT ~ cbind(1,trl, trl^p), start = c(p = -.2), algorithm =
> "plinear", data=df.one)
>
> Yields the following error message....
> "Error in numericDeriv(form[[3]], names(ind), env) :
>    Missing value or an infinity produced when evaluating the model"
>
> Now, recode trial from 1-15 and run the same model.
> >fit.pw  <-nls(RT ~ cbind(1,trl, trl^p), start = c(p = -.2), algorithm =
> "plinear", data=df.one)
>
> Seems to work fine now...
> Nonlinear regression model
>   model:  RT ~ cbind(1, trl, trl^p)
>    data:  df.one
>          p      .lin1            .lin.trl       .lin3
>    -0.2845   200.3230    -8.9467   904.7582
>  residual sum-of-squares: 555915
>
> Number of iterations to convergence: 11
>
> Any idea why having a zero for the first value of X causes this problem?
>
> Thanks in advance,
>
> Rick DeShon
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list