Re: [R] Error in x[good, ] * w : non-conformable arrays

From: Prof Brian Ripley <>
Date: Tue 09 May 2006 - 21:31:20 EST

Who said that an offset can be an array in glm? (It can be in other contexts).

On Tue, 9 May 2006, Mark Clements wrote:

>> From posts in Sep 2004 and Feb 2005, glm() was raising "Error in x[good, ] * w : non-conformable arrays". I can reproduce this error using:

Neither of those were using an offset, and the second was using a home-brewed family. I guess the issue was with the weights.

> df1 = data.frame(u=1:10,
> v=rpois(10,10),
> z=array(1,10,dimnames=list(1:10)))
> glm(v~u+offset(log(z)), data=df1, family=poisson)
> -- which seems to be due to the variable z have dimnames.

Rather, having a dim.

In, the error is traced to some weight vector w having class "numeric" on the first iteration and class "array" on the second iteration. Would this problem be solved by changing "x[good, ] * w" in to "x[good, ] * as.numeric(w)"?

That's not the place to fix it, and you want as.vector() or drop() rather than as.numeric. It would be more informative to check that the offset(s) are vectors and numeric.

> With kind regards, Mark Clements.
> ______________________________________________
> mailing list
> PLEASE do read the posting guide!

Brian D. Ripley,        
Professor of Applied Statistics,
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________ mailing list
PLEASE do read the posting guide!
Received on Tue May 09 21:37:15 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 09 May 2006 - 22:10:01 EST.

Mailing list information is available at Please read the posting guide before posting to the list.