Re: R-alpha: R16 problems

Thomas Lumley (thomas@biostat.washington.edu)
Tue, 11 Feb 1997 09:17:48 -0800 (PST)


Date: Tue, 11 Feb 1997 09:17:48 -0800 (PST)
From: Thomas Lumley <thomas@biostat.washington.edu>
To: Jim Lindsey <jlindsey@luc.ac.be>
Subject: Re: R-alpha: R16 problems
In-Reply-To: <9702110804.AA20113@alpha.luc.ac.be>

On Tue, 11 Feb 1997, Jim Lindsey wrote:

> 3. suppose x and y are numeric and gp is a factor variable. Construct
> a data.frame:
> z <- data.frame(y,gp,x)
> attach(z)
> model.matrix(y~x+gp,data=z)
> This gives a matrix with columns
> (Intercept) x2 x3 x4 gp
> The order in the formula and in the data.frame get all mixed up. lm
> and glm do not use this sort of thing, but apparently a lot of S
> functions do.

I have reported this one before.  model.matrix() does not check the names 
in the data frame you hand it.  It only works if the data argument (is 
identical to) the result of model.frame(formula,data).  One temporary 
solution is to replace model.matrix(formula,data) by 
model.matrix(formula,model.frame(formula,data))

> 4. If gee is used with clusters of size 3, it cannot print the
> correlation matrix but says subscript out of bounds. However, the
> first time I tried it, it gave a segmentation fault so there appears
> to be something wrong with subscript bound checking.

The "subscript out of bounds" is an error in the original gee code -- it 
happens in S-PLUS as well. print.gee() contains the lines
       cat("\n\nWorking Correlation[1:4,1:4]\n")
       print(x$working.correlation[1:4, 1:4], digits = digits)

These should be replaced by 
	four<-min(4,dim(x$working.correlation)[[1]])
        cat("\n\nWorking Correlation[1:",four,",1:",four,"]\n")
        print(x$working.correlation[1:four, 1:four], digits = digits)

Here is a diff file that does it:
62,63c62,66
<         cat("\n\nWorking Correlation[1:4,1:4]\n")
<         print(x$working.correlation[1:4, 1:4], digits = digits)
---
> ###<TSL>
> 	four<-min(4,dim(x$working.correlation)[[1]])
>         cat("\n\nWorking Correlation[1:",four,",1:",four,"]\n")
>         print(x$working.correlation[1:four, 1:four], digits = digits)
> ###</TSL>





Thomas Lumley
------------------------------------------------------+------
Biostatistics		: "Never attribute to malice what  :
Uni of Washington	:  can be adequately explained by  :
Box 357232		:  incompetence" - Hanlon's Razor  :
Seattle WA 98195-7232	:				   :
------------------------------------------------------------

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
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
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-