Re: R-alpha: glm and nlm

Thomas Lumley (thomas@biostat.washington.edu)
Mon, 18 Nov 1996 09:10:04 -0800 (PST)


Date: Mon, 18 Nov 1996 09:10:04 -0800 (PST)
From: Thomas Lumley <thomas@biostat.washington.edu>
To: Jim Lindsey <jlindsey@luc.ac.be>
Subject: Re: R-alpha: glm and nlm
In-Reply-To: <9611180844.AA29233@alpha.luc.ac.be>

On Mon, 18 Nov 1996, Jim Lindsey wrote:

> 1.Set
>   a <- y~x
>   b <- y~z
>   d <- c(a,b)
>   Why is is.language(a) true but is.language(d[1]) false? I need this
>   or a list for programs that have several regressions in the same
>   model, e.g. for mean and variance.

is.language(d[[1]]) is TRUE, which should provide a reasonable 
substitute. d[1] is *not* a formula, it is a list containing one formula. 
This is what happens when you use vector subscripting on a list (except 
for lists of numbers which are automagically converted to vectors).


> 3.anova() applied to a glm gives an error, something like NA instead
>   of logical in if(np>1)  (from memory, sorry)

There is a bug in anova.glm.  I have sent a fix to Ross. Here is a patch
for src/library/base/glm.  The problem is that glm$x is FALSE if the
design matrix is not included but anova.glm only tests for NULL. 


*** glm.orig    Mon Nov 18 09:03:54 1996
--- glm Mon Nov 18 09:05:15 1996
***************
*** 277,283 ****
        # extract variables from model
  
        varlist <- attr(object$terms, "variables")
!       if(!is.null(object$x)) x <- object$x
        else {
                if(is.null(object$model)) {
                        if(is.null(object$data))
--- 277,283 ----
        # extract variables from model
  
        varlist <- attr(object$terms, "variables")
!       if(!is.null(object$x) && !(is.logical(object$x) || 
object$x==FALSE)) x <- object$x
        else {
                if(is.null(object$model)) {
                        if(is.null(object$data))



thomas lumley       Penguin: the name is supposed to come from 
PhD student         the Welsh _pen_gwyn_ meaning "white head". 
Biostatistics       As penguins have black heads and do not live 
U. Washington       within 10000 miles of Wales it is difficult 
Seattle WA 98195    to see how this theory arose.


=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-testers mailing list -- For info or help, send "info" or "help",
To [un]subscribe, send "[un]subscribe"
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-