[Rd] nobs() and logLik()
Prof Brian Ripley
ripley at stats.ox.ac.uk
Fri Jan 20 07:20:30 CET 2012
I do wonder why people use zero weights rather than 'subset', and I
don't particularly like the discontinuity as a weight goes to zero.
But this came up for glm() and it would be better to be consistent, so
thanks for pointing out the nls() cases. We'll alter them.
On 20/01/2012 05:30, Berwin A Turlach wrote:
> Dear all,
>
> I am studying a bit the various support functions that exist for
> extracting information from fitted model objects.
>
>> From the help files it is not completely clear to me whether the number
> returned by nobs() should be the same as the "nobs" attribute of the
> object returned by logLik().
>
> If so, then there is a slight inconsistency in the methods for 'nls'
> objects with logLik.nls() taking zero weights into account while
> nobs.nls() does not. Admittedly, the help page of nobs() states that:
>
> For 'lm' and 'glm' fits, observations with zero weight are not
> included.
>
> i.e. does not comment on what nls does.
>
> But I wonder whether the following behaviour is desirable:
>
> R> DNase1<- subset(DNase, Run == 1)
> R> fm3DNase2<- nls(density ~ Asym/(1 + exp((xmid - log(conc))/scal)),
> + data = DNase1, weights=c(0,rep(1,14),0),
> + start = list(Asym = 3, xmid = 0, scal = 1))
> R> nobs(fm3DNase2)
> [1] 16
>> logLik(fm3DNase2)
> 'log Lik.' 42.62777 (df=4)
>> nobs(logLik(fm3DNase2))
> [1] 14
>
> Cheers,
>
> Berwin
>
> ______________________________________________
> 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