There sure does appear to be a bug in the code. In particular, with dispatching, the allEffects
code calls effect
which calls Effect.lm
. This particular is recreated also with
Effect.lm("x", mod=model)
# Error in mod.matrix %*% mod$coefficients[!is.na(mod$coefficients)] :
# non-conformable arguments
The error appears to come from line 30 of body of this function
body(effects:::Effect.lm)[[30]]
# mod.matrix <- mod.matrix[, !is.na(mod$coefficients)]
The problem occurs when you only have 1 non-NA coefficient (as you would with a single regressor and no intercept). The problem is that when you do this subset on a single column, the result is automatically don't cast to a vector rather than a matrix. We can create our own version of the function that fixes this problem
my.Effect.lm<-effects:::Effect.lm
body(my.Effect.lm)[[30]] <- quote(mod.matrix <- mod.matrix[, !is.na(mod$coefficients), drop=FALSE])
environment(my.Effect.lm) <- asNamespace("effects")
Then
model <- lm(y ~ 0 + x)
plot(my.Effect.lm("x", model))
should work. I must admit i haven't figured out how to get allEffects
to work. I can't remember how to change how the S3 dispatch works when it resolved functions in different namespaces. There doesn't seem to be any easy way to fix the function that's actually located in the effects
namespace.
So in general the function should work without intercepts as long as you have more than one regressor. You may want to contact the package author to report this problem.