, January, 18 11:16 AM
To: Guelman, Leo
Cc: r-help@r-project.org; Charles C. Berry
Subject: Re: [R] Order of formula terms in model.matrix
On 18 Jan 2016, at 16:49 , Guelman, Leo wrote:
> Is it really the same model?
No, and I didn't say that they would be. I did say that they would b
On 18 Jan 2016, at 16:49 , Guelman, Leo wrote:
> Is it really the same model?
No, and I didn't say that they would be. I did say that they would be in the
all-factor case, which does seem to be right:
> df$trt <- factor(df$trt)
> fit1 <- glm(y ~ x1:trt + f1:trt, data = df, family = binomial)
Is it really the same model?
Following the example provided by Lars:
set.seed(1)
x1 <- rnorm(100)
f1 <- factor(sample(letters[1:3], 100, replace = TRUE))
trt <- sample(c(-1,1), 100, replace = TRUE)
y <- factor(sample(c(0,1), 100, T))
df <- data.frame(y=y, x1=x1, f1=f1, trt=trt)
fit1 <- glm(y ~ x
> On 17 Jan 2016, at 19:34 , Charles C. Berry wrote:
>
>
> IIRC, there are some heuristics involved harking back to the White Book. I
> recall there have been discussions of whether and how this could be fixed
> before on this list and or R-devel, but I cannot seem to lay my browser on
> the
Question: I(a*b) would work as long as both “a" and “b” are numeric. Is there a
way I can force the behaviour of model.matrix when one of these variables is a
factor (as in "f1:trt" from my example below)?
Specifically, based on my example below, I would like to always return the
first matrix
This is very helpful, thanks!
Lars.
> On Jan 17, 2016, at 1:34 PM, Charles C. Berry wrote:
>
> On Sun, 17 Jan 2016, Lars Bishop wrote:
>
>> I’d appreciate your help on understanding the following.
>
>> It is not very clear to me from the model.matrix documentation, why simply
>> changing t
On Sun, 17 Jan 2016, Lars Bishop wrote:
I’d appreciate your help on understanding the following.
It is not very clear to me from the model.matrix documentation, why
simply changing the order of terms in the formula may change the number
of resulting columns. Please note I’m purposely not in
I’d appreciate your help on understanding the following.
It is not very clear to me from the model.matrix documentation, why simply
changing the order of terms in the formula may change the number of resulting
columns. Please note I’m purposely not including main effects in the model
formula i
8 matches
Mail list logo