[R] No answer in anova.nls

Gabor Grothendieck ggrothendieck at gmail.com
Tue Aug 12 20:22:51 CEST 2008


You can compare non-nested nls fits using the AIC command. Although
that does not give a formal hypothesis test there are rules of thumb for
using the AIC.

On Tue, Aug 12, 2008 at 2:13 AM, Nazareno Andrade
<nazareno at lsd.ufcg.edu.br> wrote:
> Dear R-helpers,
>
> I am trying to check whether a model of the form y(t) = a/(1 +b*t) fits the
> curve of downloads per day of a file in a specific online community better
> than a model of the form y(t) = a*exp(-b*t). For that, I used nls to fit
> both models and I am now trying to compare the fits with anova. The problem
> I find is that anova does not report an F statistic or a p-value when I
> compare these two models.
>
> The data for a file is typically the following:
>> d
>   V1  V2
> 1   1 293
> 2   2 101
> 3   3  63
> 4   4  53
> 5   5  42
> 6   6  19
> 7   7  28
> 8   8  23
> 9   9  18
> 10 10  17
> 11 11  14
> 12 12  18
> 13 13   5
> 14 14   9
> 15 15  10
> 16 15   0
>
> My code:
>
> d <- read.table(url("http://ece.ubc.ca/~nazareno/85247.arrivalRates<http://ece.ubc.ca/%7Enazareno/85247.arrivalRates>
> "))
> plot(d)
> f.exp.nw <- nls(V2 ~ a. * exp(-b. * V1), data = d, list( a. = d$V2[1], b. =
> 0.05))
> f.exp5.nw <- nls(V2 ~ a. / (1+ b. *V1), data = d, list( a. = d$V2[1], b. =
> 2))
> lines(d$V1, predict(f.exp.nw), col = "royalblue")
> lines(d$V1, predict(f.exp5.nw), col = "orange")
>
> anova(f.exp.nw, f.exp5.nw)
>
> However, the output from anova.nls is:
>
> Analysis of Variance Table
>
> Model 1: V2 ~ a. * exp(-b. * V1)
> Model 2: V2 ~ a./(1 + b. * V1)
>  Res.Df Res.Sum Sq Df Sum Sq F value Pr(>F)
> 1     13     4994.9
> 2     13      314.7  0    0.0
>
> and I cannot interpretate the lack of an F value. Looking at the
> implementation of the anova.nls() function, this seems to be related to the
> fact that the residuals' degrees of freedom are the same, but I could not
> find anywhere more information on whether they were required to be
> different. Thus, I'd greatly appreciate if you could spot any mistakes I
> might be doing or a (preferably online) reference for more on this issue.
>
>
> As a side question, it would be great also if someone with more experience
> on this matter could confirm with me that the proper direction for checking
> whether "the y(t) = a/(1 +b*t) form models more precisely the behavior of
> downloads of files in this communtiy" by quantifying for how many files it
> outperforms the exponential model.
>
> thank you very much in advance,
> Nazareno
>
>        [[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