A problem with anova()

View: New views
4 Messages — Rating Filter:   Alert me  

A problem with anova()

by Guru S :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

  
Hi,

I fitted tree growth data with Chapman-Richards growth function using nls.

summary(fit.nls)

Formula: HEIGHT ~ A * (1 - exp(-B * AGE))^C

Parameters:

  Estimate Std. Error t value Pr(>|t|)    
A 29.007627  0.270485  107.24  <2e-16 ***
B  0.030813  0.001095  28.13  <2e-16 ***
C  1.849405  0.068659  26.94  <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 1.879 on 713 degrees of freedom

Algorithm "port", convergence message: relative convergence (4)

When I try to run the anova() function I get this:

anova(fit.nls)
Error in anova.nls(fit.nls) : anova is only defined for sequences of "nls" objects

Could you tell me what the problem is?

Thanks & Regards,
Guru S

        [[alternative HTML version deleted]]


______________________________________________
R-help@... 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.

Re: A problem with anova()

by Peter Dalgaard :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Guru S wrote:

>  
> Hi,
>
> I fitted tree growth data with Chapman-Richards growth function using nls.
>
> summary(fit.nls)
>
> Formula: HEIGHT ~ A * (1 - exp(-B * AGE))^C
>
> Parameters:
>
>   Estimate Std. Error t value Pr(>|t|)    
> A 29.007627  0.270485  107.24  <2e-16 ***
> B  0.030813  0.001095  28.13  <2e-16 ***
> C  1.849405  0.068659  26.94  <2e-16 ***
> ---
> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
>
> Residual standard error: 1.879 on 713 degrees of freedom
>
> Algorithm "port", convergence message: relative convergence (4)
>
> When I try to run the anova() function I get this:
>
> anova(fit.nls)
> Error in anova.nls(fit.nls) : anova is only defined for sequences of "nls" objects
>
> Could you tell me what the problem is?
>
>  
It's what the message says: You can't run anova() on one model, only
compare several, as in
anoval(fit.nls, fit2.nls).

It is not clear what anova(fit.nls) should do in the nonlinear case ,
since you cannot in general remove parameters successively from the
model (notice, for your own model, that C is meaningless if B=0 and both
B and C are meaningless if A=0).

--
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@...)              FAX: (+45) 35327907

______________________________________________
R-help@... 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.

Re: A problem with anova()

by Christian Ritz-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Peter,

I think one option for what anova could do in the nonlinear case is to report the analysis
of variance (or deviance) table obtained when doing a lack-of-fit test, that is comparing
the nonlinear regression model to an appropriate ANOVA model. This is for example the use
of anova in the package 'drc':

## Using the package 'drc' from CRAN
library(drc)

## Fitting the 4-par log-logistic model
ryegrass.ll <- drm(rootl ~ conc, data = ryegrass, fct = LL.4())

## ANOVA table for the lack-of-fit test
anova(ryegrass.ll)



Christian



Peter Dalgaard wrote:

> Guru S wrote:
>>   Hi,
>>
>> I fitted tree growth data with Chapman-Richards growth function using
>> nls.
>> summary(fit.nls)
>> Formula: HEIGHT ~ A * (1 - exp(-B * AGE))^C
>> Parameters:
>>   Estimate Std. Error t value Pr(>|t|)    A 29.007627  0.270485  
>> 107.24  <2e-16 ***
>> B  0.030813  0.001095  28.13  <2e-16 ***
>> C  1.849405  0.068659  26.94  <2e-16 ***
>> ---
>> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
>> Residual standard error: 1.879 on 713 degrees of freedom
>>
>> Algorithm "port", convergence message: relative convergence (4)
>> When I try to run the anova() function I get this:
>>
>> anova(fit.nls)
>> Error in anova.nls(fit.nls) : anova is only defined for sequences of
>> "nls" objects
>>
>> Could you tell me what the problem is?
>>
>>  
> It's what the message says: You can't run anova() on one model, only
> compare several, as in
> anoval(fit.nls, fit2.nls).
> It is not clear what anova(fit.nls) should do in the nonlinear case ,
> since you cannot in general remove parameters successively from the
> model (notice, for your own model, that C is meaningless if B=0 and both
> B and C are meaningless if A=0).
>

______________________________________________
R-help@... 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.

Re: A problem with anova()

by Peter Dalgaard :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Christian Ritz wrote:

> Hi Peter,
>
> I think one option for what anova could do in the nonlinear case is to
> report the analysis of variance (or deviance) table obtained when
> doing a lack-of-fit test, that is comparing the nonlinear regression
> model to an appropriate ANOVA model. This is for example the use of
> anova in the package 'drc':
>
> ## Using the package 'drc' from CRAN
> library(drc)
>
> ## Fitting the 4-par log-logistic model
> ryegrass.ll <- drm(rootl ~ conc, data = ryegrass, fct = LL.4())
>
> ## ANOVA table for the lack-of-fit test
> anova(ryegrass.ll)
>
I think I prefer to do that explicitly. You don't always have an
"appropriate ANOVA model" with which to compare. And anova.nls() will do
this just fine, you just have to remember to put the nonlinear model
first (because of S3 dispatching).

> boc <-
read.table("http://staff.pubhealth.ku.dk/~pd/varians_regression/data/bif.txt",header=T)
> a.fit <- lm(boc~factor(days), data=boc)
> n.fit <- nls(boc~gamma*exp(-beta/days), start=c(gamma=250, beta=0.8),
data=boc)
> anova(n.fit,a.fit)
Analysis of Variance Table

Model 1: boc ~ gamma * exp(-beta/days)
Model 2: boc ~ factor(days)
  Res.Df Res.Sum Sq Df  Sum Sq F value Pr(>F)
1     22    2585.39
2     18    2130.50  4  454.89  0.9608 0.4527


--
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@...)              FAX: (+45) 35327907

______________________________________________
R-help@... 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.