Displaying 10 results from an estimated 10 matches for "x1q".
Did you mean:
x11
2017 Oct 15
0
Bug in model.matrix.default for higher-order interaction encoding when specific model terms are missing
...bles, each being a factor:
df <- expand.grid(X1=c("p","q"), X2=c("A","B","C"))
print(model.matrix(~(X1+X2)^2 ,data=df))
print(model.matrix(~(X1+X2)^2 -X1,data=df))
print(model.matrix(~(X1+X2)^2 -X2,data=df))
The result is:
(Intercept) X1q X2B X2C X1q:X2B X1q:X2C
1 1 0 0 0 0 0
2 1 1 0 0 0 0
3 1 0 1 0 0 0
4 1 1 1 0 1 0
5 1 0 0 1 0 0
6 1 1 0 1 0 1
(Intercept) X2B X2C...
2017 Oct 12
2
Bug in model.matrix.default for higher-order interaction encoding when specific model terms are missing
Hi,
I recently ran into an inconsistency in the way model.matrix.default
handles factor encoding for higher level interactions with categorical
variables when the full hierarchy of effects is not present. Depending on
which lower level interactions are specified, the factor encoding changes
for a higher level interaction. Consider the following minimal reproducible
example:
--------------
>
2017 Oct 27
2
Bug in model.matrix.default for higher-order interaction encoding when specific model terms are missing
...p","q"), X2=c("A","B","C"))
>> print(model.matrix(~(X1+X2)^2 ,data=df))
>> print(model.matrix(~(X1+X2)^2 -X1,data=df))
>> print(model.matrix(~(X1+X2)^2 -X2,data=df))
>>
>> The result is:
>>
>> (Intercept) X1q X2B X2C X1q:X2B X1q:X2C
>> 1 1 0 0 0 0 0
>> 2 1 1 0 0 0 0
>> 3 1 0 1 0 0 0
>> 4 1 1 1 0 1 0
>> 5 1 0 0 1 0 0
>> 6...
2017 Nov 02
2
Bug in model.matrix.default for higher-order interaction encoding when specific model terms are missing
...C"))
>> >> print(model.matrix(~(X1+X2)^2 ,data=df))
>> >> print(model.matrix(~(X1+X2)^2 -X1,data=df))
>> >> print(model.matrix(~(X1+X2)^2 -X2,data=df))
>> >>
>> >> The result is:
>> >>
>> >> (Intercept) X1q X2B X2C X1q:X2B X1q:X2C
>> >> 1 1 0 0 0 0 0
>> >> 2 1 1 0 0 0 0
>> >> 3 1 0 1 0 0 0
>> >> 4 1 1 1 0 1 0
>> >> 5 1 0...
2017 Nov 04
2
Bug in model.matrix.default for higher-order interaction encoding when specific model terms are missing
...2)^2 ,data=df))
>> >> >> print(model.matrix(~(X1+X2)^2 -X1,data=df))
>> >> >> print(model.matrix(~(X1+X2)^2 -X2,data=df))
>> >> >>
>> >> >> The result is:
>> >> >>
>> >> >> (Intercept) X1q X2B X2C X1q:X2B X1q:X2C
>> >> >> 1 1 0 0 0 0 0
>> >> >> 2 1 1 0 0 0 0
>> >> >> 3 1 0 1 0 0 0
>> >> >> 4 1 1 1 0 1 0...
2017 Oct 31
0
Bug in model.matrix.default for higher-order interaction encoding when specific model terms are missing
...A","B","C"))
> >> print(model.matrix(~(X1+X2)^2 ,data=df))
> >> print(model.matrix(~(X1+X2)^2 -X1,data=df))
> >> print(model.matrix(~(X1+X2)^2 -X2,data=df))
> >>
> >> The result is:
> >>
> >> (Intercept) X1q X2B X2C X1q:X2B X1q:X2C
> >> 1 1 0 0 0 0 0
> >> 2 1 1 0 0 0 0
> >> 3 1 0 1 0 0 0
> >> 4 1 1 1 0 1 0
> >> 5 1 0 0 1 0...
2017 Nov 06
2
Bug in model.matrix.default for higher-order interaction encoding when specific model terms are missing
...print(model.matrix(~(X1+X2)^2 -X1,data=df))
>> >> >> >> print(model.matrix(~(X1+X2)^2 -X2,data=df))
>> >> >> >>
>> >> >> >> The result is:
>> >> >> >>
>> >> >> >> (Intercept) X1q X2B X2C X1q:X2B X1q:X2C
>> >> >> >> 1 1 0 0 0 0 0
>> >> >> >> 2 1 1 0 0 0 0
>> >> >> >> 3 1 0 1 0 0 0
>> >> >> >> 4...
2017 Nov 02
0
Bug in model.matrix.default for higher-order interaction encoding when specific model terms are missing
...rint(model.matrix(~(X1+X2)^2 ,data=df))
> >> >> print(model.matrix(~(X1+X2)^2 -X1,data=df))
> >> >> print(model.matrix(~(X1+X2)^2 -X2,data=df))
> >> >>
> >> >> The result is:
> >> >>
> >> >> (Intercept) X1q X2B X2C X1q:X2B X1q:X2C
> >> >> 1 1 0 0 0 0 0
> >> >> 2 1 1 0 0 0 0
> >> >> 3 1 0 1 0 0 0
> >> >> 4 1 1 1 0 1 0
> >> &...
2017 Nov 04
0
Bug in model.matrix.default for higher-order interaction encoding when specific model terms are missing
...t; >> >> print(model.matrix(~(X1+X2)^2 -X1,data=df))
> >> >> >> print(model.matrix(~(X1+X2)^2 -X2,data=df))
> >> >> >>
> >> >> >> The result is:
> >> >> >>
> >> >> >> (Intercept) X1q X2B X2C X1q:X2B X1q:X2C
> >> >> >> 1 1 0 0 0 0 0
> >> >> >> 2 1 1 0 0 0 0
> >> >> >> 3 1 0 1 0 0 0
> >> >> >> 4 1 1 1...
2017 Nov 06
0
Bug in model.matrix.default for higher-order interaction encoding when specific model terms are missing
...+X2)^2 -X1,data=df))
> >> >> >> >> print(model.matrix(~(X1+X2)^2 -X2,data=df))
> >> >> >> >>
> >> >> >> >> The result is:
> >> >> >> >>
> >> >> >> >> (Intercept) X1q X2B X2C X1q:X2B X1q:X2C
> >> >> >> >> 1 1 0 0 0 0 0
> >> >> >> >> 2 1 1 0 0 0 0
> >> >> >> >> 3 1 0 1 0 0 0
> >> >> >...