[R] Possible Bug in Effects Package
John Fox
jfox at mcmaster.ca
Sat Oct 9 17:10:04 CEST 2010
Dear Peter and Luciano,
I agree that this is a bug, and I'll try to fix it as soon as I have a
chance -- probably the week after next.
I was rather surprised that effect() works in a model without a constant,
but it does seem to:
> model2<- glm( prop ~ -1 + tra, weights = tries, data = test, family =
binomial)
> allEffects(model2)
model: prop ~ -1 + tra
tra effect
tra
V D C L
0.4129073 0.4731815 0.5454545 0.4548451
> model3<- glm( prop ~ tra, weights = tries, data = test, family = binomial)
> allEffects(model3)
model: prop ~ tra
tra effect
tra
V D C L
0.4129073 0.4731815 0.5454545 0.4548451
> 1/(1 + exp(-coef(model2)))
traV traD traC traL
0.4129073 0.4731815 0.5454545 0.4548451
I expect that this is peculiar to the one-way classification, and that
effect() will not work in general for a model without a constant (which will
violate marginality).
Thanks for bringing the problem to my attention. I'm afraid that I've been
so busy this fall that I've been unable to monitor the r-help list.
John
--------------------------------
John Fox
Senator William McMaster
Professor of Social Statistics
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
web: socserv.mcmaster.ca/jfox
> -----Original Message-----
> From: Peter Ehlers [mailto:ehlers at ucalgary.ca]
> Sent: October-09-10 10:20 AM
> To: Luciano Selzer
> Cc: r-help at r-project.org; John Fox
> Subject: Re: [R] Possible Bug in Effects Package
>
> On 2010-10-02 11:47, Luciano Selzer wrote:
> > Dear List,
> > I find Effects package very useful, but I believe I have found a bug in
> > allEffects function. Please consider the following code:
> >
> > test<- data.frame(tries= round(runif(40, 5, 300)),
> > tra = gl(4, 10, labels = c("V", "D", "C", "L")),
> > prop= runif(40, 0, 1))
> >
> > test$success<- round(with(test, tries*prop))
> > test$prop<- with(test, success/tries)
> >
> > model<- glm( cbind(success, tries) ~ -1 + tra, data = test, family =
> > binomial)
> > allEffects(model)
> >
> > #Error en eval(expr, envir, enclos) : objeto 'tra' no encontrado
> >
> > model2<- glm( prop ~ -1 + tra, weights = tries, data = test, family =
> > binomial)
> > allEffects(model2)
> > #Works
> >
> > On a quick search on the internet I've found nothing about this. Is this
a
> > bug?
> >
>
> I think that this is indeed a bug, probably due to the use of
> the all.vars() function in effects:::analyze.model().
>
> The obvious workaround is to specify your model as in model2
> above or, if you want to use the matrix-response version, then
> give the matrix a name and use that in your model:
>
> respmat <- with(test, cbind(success, tries - success))
> ##[correcting your cbind]
> mod <- glm(respmat ~ ....)
>
> -Peter Ehlers
>
> > Thanks for your time
> >
> >
> > Luciano
> >
> > [[alternative HTML version deleted]]
> >
More information about the R-help
mailing list