>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: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. In glm.fit(), 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 glm.fit() to "x[good, ] * as.numeric(w)"? With kind regards, Mark Clements. https://stat.ethz.ch/pipermail/r-help/2005-February/066784.html https://stat.ethz.ch/pipermail/r-help/2004-September/057888.html
Prof Brian Ripley
2006-May-09 11:31 UTC
[R] Error in x[good, ] * w : non-conformable arrays
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 glm.fit(), 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 glm.fit() 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. > > https://stat.ethz.ch/pipermail/r-help/2005-February/066784.html > https://stat.ethz.ch/pipermail/r-help/2004-September/057888.html > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >-- 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