[R] Error Message - "effects" package

David Winsemius dwinsemius at comcast.net
Fri Jan 21 00:06:51 CET 2011


On Jan 20, 2011, at 5:53 PM, Lars Bishop wrote:

> Hi,
>
> I'm running R 2.11.1 on Windows 32-bit. I fitted a glm to a "large"  
> data set
> with no problems (i.e., nothing is wrong with the created glm object).
>
> However, when I try to use the "effects" package to plot the effects  
> I get
> the error message shown below. I get the same message if I try to  
> plot a
> single effect. Any idea what could be wrong here?

Did you heed this warning?
"Consequently, formulas that include calls to as.factor, factor, or  
numeric (as, e.g., in as.factor(income)) will cause errors. Instead,  
create the modified variables outside of the model formula (e.g.,  
fincome <- as.factor(income)) and use these in the model formula."


>
>
> glm.eff <- allEffects(glm1)
> plot(glm.eff)
>
>
> Error in apply(mod.matrix[, components], 1, prod) :
>  subscript out of bounds
> In addition: Warning messages:
> 1: In `[<-.factor`(`*tmp*`, ri, value = c(1, 1, 1, 1, 1, 1, 1, 1,  
> 1,  :
>  invalid factor level, NAs generated
> 2: In matrix(apply(as.matrix(X.mod[, facs]), 2, mean), nrow =
> nrow(mod.matrix),  :
>  data length exceeds size of matrix
> 3: In matrix(apply(as.matrix(X.mod[, covs]), 2, typical), nrow =
> nrow(mod.matrix),  :
>  data length exceeds size of matrix
>
> Thanks,
> Lars.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list