Re: [Rd] nobs() and logLik()

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Fri, 20 Jan 2012 06:20:30 +0000

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

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Fri 20 Jan 2012 - 06:23:28 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 20 Jan 2012 - 13:00:10 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive