[Rd] Residual DF of NLS models (PR#14194)
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Jan 26 13:04:23 CET 2010
Can we please have a reproducible example (as we did ask in the
FAQ, the posting guide ...).
On Tue, 26 Jan 2010, han at enfor.dk wrote:
> Full_Name: Henrik Aalborg Nielsen
> Version: 2.10
> OS: Linux (SLES 10 / openSUSE 11.1)
> Submission from: (NULL) (77.66.63.89)
>
>
> There seems to be a bug in df.residual.nls which is triggered when nls is called
> with argument na.action = na.exclude; in that case 'resid(object)' will contain
> NA-values which should be disregarded when counting the number of residuals:
>
> df.residual.nls <- function(object, ...) {
> w <- object$weights
> n <- if(!is.null(w)) sum(w != 0) else length(resid(object))
> n - length(coef(object))
> }
>
> The bug cause the F-test of anova.nls to be wrong.
>
> Replace 'length(resid(object))' with 'sum(!is.na(resid(object)))' ?
>
> ... and thank you for producing this fantastic software!
>
> BR
> Henrik
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
--
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
More information about the R-devel
mailing list