While investigating some fundamentals of multiple regression, I decided to try and compare my manual efforts to those of the “effects” package, by John Fox. I’ve generated variables with some relationships, and want to get adjusted means for a factor when controlling for the influence of a continuous variable.
I have become stalled, however, as the effect function in the effects package returns an error “invalid type (builtin) for variable ‘c'”
When I check the type of variable ‘c’ using typeof(c), I’m told it is of type double, as I constructed it to be.
- What could be the cause of this error?
- Is the variable ‘c’ being coerced for some reason to type ‘builtin’?
Here is my code:
set.seed(1986)
y <- rnorm(100)
f <- sapply(y, function(x) if(x < 0) 1 else 2)
f.f <- as.factor(f)
set.seed(1987)
c <- rnorm(100, 0, .1) + y + f
an3 <- lm(y ~ f.f + c); summary(an3)
ef <- effect("f.f", an3)
cis not a good choice for a a variable name. It’s an extremely commonly-used built-in function in R.Changing
ctodworks for me: