[R] effect() error: non-conformable arguments

John Fox jfox at mcmaster.ca
Mon Feb 11 17:03:39 CET 2013


Dear Elisha,

It's amazing how informative posting a reproducible example can be:

The problem is that your model has aliased coefficients, and effect() can't handle that. Coincidentally, the development version of the effects package on R-Forge *can* handle models with aliased coefficients, so you could install the package from there via install.packages("effects", repos="http://R-Forge.R-project.org"). Then:

> Help<-read.csv(file.choose(), sep=",", header=T) # note, BTW, that the values you give for sep and header are the defaults
> Help$WeeksOut<-as.factor(Help$WeeksOut)
> Help$Run<-as.factor(Help$Run)
> GLM<-glm(NumberSpecies~Treatment*WeeksOut+Run+Tree., family=poisson (link=log), data=Help)
> summary(effect("Treatment", GLM))

 Treatment effect
Treatment
    Cont1 Cont2Cues    P.cryp    P.quer    Pseudo 
 1.453279  1.428373  1.741889  1.799684  1.850168 

 Lower 95 Percent Confidence Limits
Treatment
    Cont1 Cont2Cues    P.cryp    P.quer    Pseudo 
 1.265800  1.242642  1.535699  1.590321  1.615102 

 Upper 95 Percent Confidence Limits
Treatment
    Cont1 Cont2Cues    P.cryp    P.quer    Pseudo 
 1.668526  1.641864  1.975763  2.036610  2.119447 
Warning message:
In analyze.model(term, mod, xlevels, default.levels) :
  Treatment is not a high-order term in the model

This works, as you can see, but I'd pay attention to the warning.

Best,
 John

On Mon, 11 Feb 2013 10:22:12 -0500
 Elisha Sigmon <elisha.sigmon at gmail.com> wrote:
> Sorry about that. Attached is the relevant data and the following is the
> code and error.
> 
> >Help<-read.csv("R-help-effect.csv", sep=",", header=T)
> >Help$WeeksOut<-as.factor(Help$WeeksOut)
> >Help$Run<-as.factor(Help$Run)
> >GLM<-glm(NumberSpecies~Treatment*WeeksOut+Run+Tree., family=poisson
> (link=log), data=Help)
> >summary(effect("Treatment", GLM))
> Error in mod.matrix %*% V : non-conformable arguments
> 
> 
> Thanks!
> 
> 
> On Fri, Feb 8, 2013 at 8:57 AM, John Fox <jfox at mcmaster.ca> wrote:
> 
> > Dear Elisha,
> >
> > It's impossible to tell from the information that you provide what the
> > source of the problem is. The gold standard for a problem report is
> > "commented, minimal, self-contained, reproducible code" (quoting from the
> > text at the bottom of all r-help postings) that would allow me to track
> > down
> > the error, but you don't even show the model that you've fit. I suspect
> > that
> > there's something about the model that's incompatible with the effect()
> > function but what that might be is impossible to know from your message.
> >
> > Please provide some more details and ideally a reproducible example.
> >
> > Best,
> >  John
> >
> > -----------------------------------------------
> > John Fox
> > Senator McMaster Professor of Social Statistics
> > Department of Sociology
> > McMaster University
> > Hamilton, Ontario, Canada
> >
> >
> >
> > > -----Original Message-----
> > > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
> > > On Behalf Of Elisha Sigmon
> > > Sent: Thursday, February 07, 2013 2:57 PM
> > > To: r-help at r-project.org
> > > Subject: [R] effect() error: non-conformable arguments
> > >
> > > I am trying to calculate adjusted means according to a glm model with a
> > > Poisson distribution using effect() in the 'effects' package. I've done
> > > this many times before with great success, but this time I'm getting an
> > > error. My model contains two factors and two covariates/blocks and I
> > > would
> > > like the adjusted mean and confidence intervals for each factor
> > > separately.
> > > The model runs without errors as does Anova() and HSD.test() on the
> > > model,
> > > but when I try to run effect("factor", model) I get the following error:
> > > Error in mod.matrix %*% V : non-conformable arguments
> > >
> > > I understand that this error indicates that matrices are being created
> > > with
> > > dimensions that can't be used in the calculations, or something to that
> > > effect. But I don't understand enough about how the effect() function is
> > > calculated to figure out where the problem is in my data. I checked my
> > > data
> > > file for any NAs, missing values, etc. and can't find any problems. If
> > > anyone has any suggestions for diagnostics or how to find the source of
> > > this error I would greatly appreciate the help.
> > >
> > > Thanks!
> > >
> > > --
> > > Elisha Sigmon
> > > Ph.D. Candidate
> > > The George Washington University
> > > Department Of Biological Sciences
> > > 2023 G St. NW Suite 340
> > > Washington, DC, USA 20052
> > >
> > >       [[alternative HTML version deleted]]
> > >
> > > ______________________________________________
> > > R-help at r-project.org mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide http://www.R-project.org/posting-
> > > guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
> >
> >
> 
> 
> -- 
> Elisha Sigmon
> Ph.D. Candidate
> The George Washington University
> Department Of Biological Sciences
> 2023 G St. NW Suite 340
> Washington, DC, USA 20052



More information about the R-help mailing list