[R] Possible Bug in Effects Package

Peter Ehlers ehlers at ucalgary.ca
Sat Oct 9 16:19:50 CEST 2010


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