search for: x2c

Displaying 15 results from an estimated 15 matches for "x2c".

Did you mean: h2c
2017 Oct 27
2
Bug in model.matrix.default for higher-order interaction encoding when specific model terms are missing
...> manually remove the X1 column from the model matrix. This gives us the > model matrix one would expect if X1 were removed from the model. We then > successfully calculate the covariance matrix. > >> mm = model.matrix(~(X1+X2)^2,data=design) >> mm > (Intercept) X1 X2B X2C X1:X2B X1:X2C > 2 1 -1 0 0 0 0 > 3 1 1 1 0 1 0 > 4 1 -1 1 0 -1 0 > 5 1 1 0 1 0 1 > 6 1 -1 0 1 0 -1 > >> mm = mm[,-2] >> solve(t(mm) %*% mm) >...
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 Nov 02
2
Bug in model.matrix.default for higher-order interaction encoding when specific model terms are missing
...rix. This gives us the >> > model matrix one would expect if X1 were removed from the model. We then >> > successfully calculate the covariance matrix. >> > >> >> mm = model.matrix(~(X1+X2)^2,data=design) >> >> mm >> > (Intercept) X1 X2B X2C X1:X2B X1:X2C >> > 2 1 -1 0 0 0 0 >> > 3 1 1 1 0 1 0 >> > 4 1 -1 1 0 -1 0 >> > 5 1 1 0 1 0 1 >> > 6 1 -1 0 1 0 -1 >> > >&g...
2017 Nov 04
2
Bug in model.matrix.default for higher-order interaction encoding when specific model terms are missing
...f X1 were removed from the model. We >> >> > then >> >> > successfully calculate the covariance matrix. >> >> > >> >> >> mm = model.matrix(~(X1+X2)^2,data=design) >> >> >> mm >> >> > (Intercept) X1 X2B X2C X1:X2B X1:X2C >> >> > 2 1 -1 0 0 0 0 >> >> > 3 1 1 1 0 1 0 >> >> > 4 1 -1 1 0 -1 0 >> >> > 5 1 1 0 1 0 1 >> >> > 6 1...
2017 Oct 31
0
Bug in model.matrix.default for higher-order interaction encoding when specific model terms are missing
...olumn from the model matrix. This gives us the > > model matrix one would expect if X1 were removed from the model. We then > > successfully calculate the covariance matrix. > > > >> mm = model.matrix(~(X1+X2)^2,data=design) > >> mm > > (Intercept) X1 X2B X2C X1:X2B X1:X2C > > 2 1 -1 0 0 0 0 > > 3 1 1 1 0 1 0 > > 4 1 -1 1 0 -1 0 > > 5 1 1 0 1 0 1 > > 6 1 -1 0 1 0 -1 > > > >> mm = mm[,-2] &gt...
2017 Nov 06
2
Bug in model.matrix.default for higher-order interaction encoding when specific model terms are missing
...>> > then >> >> >> > successfully calculate the covariance matrix. >> >> >> > >> >> >> >> mm = model.matrix(~(X1+X2)^2,data=design) >> >> >> >> mm >> >> >> > (Intercept) X1 X2B X2C X1:X2B X1:X2C >> >> >> > 2 1 -1 0 0 0 0 >> >> >> > 3 1 1 1 0 1 0 >> >> >> > 4 1 -1 1 0 -1 0 >> >> >> > 5 1 1 0 1 0 1 &...
2017 Nov 02
0
Bug in model.matrix.default for higher-order interaction encoding when specific model terms are missing
...; > model matrix one would expect if X1 were removed from the model. We > then > >> > successfully calculate the covariance matrix. > >> > > >> >> mm = model.matrix(~(X1+X2)^2,data=design) > >> >> mm > >> > (Intercept) X1 X2B X2C X1:X2B X1:X2C > >> > 2 1 -1 0 0 0 0 > >> > 3 1 1 1 0 1 0 > >> > 4 1 -1 1 0 -1 0 > >> > 5 1 1 0 1 0 1 > >> > 6 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
...el. We > >> >> > then > >> >> > successfully calculate the covariance matrix. > >> >> > > >> >> >> mm = model.matrix(~(X1+X2)^2,data=design) > >> >> >> mm > >> >> > (Intercept) X1 X2B X2C X1:X2B X1:X2C > >> >> > 2 1 -1 0 0 0 0 > >> >> > 3 1 1 1 0 1 0 > >> >> > 4 1 -1 1 0 -1 0 > >> >> > 5 1 1 0 1 0 1 > >> &gt...
2017 Nov 06
0
Bug in model.matrix.default for higher-order interaction encoding when specific model terms are missing
...>> >> >> > successfully calculate the covariance matrix. > >> >> >> > > >> >> >> >> mm = model.matrix(~(X1+X2)^2,data=design) > >> >> >> >> mm > >> >> >> > (Intercept) X1 X2B X2C X1:X2B X1:X2C > >> >> >> > 2 1 -1 0 0 0 0 > >> >> >> > 3 1 1 1 0 1 0 > >> >> >> > 4 1 -1 1 0 -1 0 > >> >> >> > 5 1 1 0...
2017 Oct 15
0
Bug in model.matrix.default for higher-order interaction encoding when specific model terms are missing
...ch 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 X1q:X2A...
2012 May 29
3
trouble automating formula edits when log or * are present; update trouble
...;c") suffixX(newFmla, "x1", "c") The last few lines of the output. See how the update misses x1 inside log(x1) or in the interaction? > newFmla <- formula(m2) > newFmla y ~ log(x1) + x2 * x3 > suffixX(newFmla, "x2", "c") y ~ log(x1) + x3 + x2c + x2:x3 > suffixX(newFmla, "x1", "c") y ~ log(x1) + x2 + x3 + x1c + x2:x3 It gets the target if the target is all by itself, but not otherwise. After messing with this for quite a while, I conclude that update was the wrong way to go because it is geared to replacement of i...
2016 Oct 03
2
suggested addition to model.matrix
Hello, All: What's the simplest way to convert a data.frame into a model.matrix? One way is given by the following example, modified from the examples in help(model.matrix): dd <- data.frame(a = gl(3,4), b = gl(4,1,12)) ab <- model.matrix(~ a + b, dd) ab0 <- model.matrix(~., dd) all.equal(ab, ab0) What do you think about replacing "model.matrix(~ a +
2010 Jan 29
1
regression with categorial variables
Hi All, I am working on an example where the electric utility is investigating the effect of size of household and the type of air conditioning on electricity consumption. I fit a multiple linear regression Electricity consumption=size of the house hold + air conditioning type There are 3 air conditioning types so I modeled them as a dummy variable Type A Type B Type C Where type A is the
2010 Feb 11
2
Suprising behavior of paste or cat?
I may be making a simple error, but I've looked at the str() of the resulting objects and I can't see any obvious reason I'm having the problem I am having, so I am reaching out to the R-help group. ?I am generating a string in my code. ?When I make a slight modification (add a comma at the end using my "lastcomma" function), I can no longer successfully write that string to
2017 Jun 21
6
RFC: Cleaning up the Itanium demangler
...\x67\x74\x71\x75\x34\x4D\x41\x64\x73\x4C\x44\x76\x72\x4D\x34\x44\x4B\x44\x54\x6E\x61\x37\x47\x77\x78\x38\x43\x27\x41\x5F\x73\x70\x69\x45\x6D\x73\x72\x53\x41\x6F\x41\x7B", "\x44\x74\x70\x74\x71\x75\x32\x43\x41\x38\x65\x6E\x9B\x72\x4D\xC1\x43\x41\x72\x4D\x6E\x77\x38\x9A\x8E\x44\x6F\x64\x2C\x53\xF9\x5F\x70\x74\x70\x69\x45\xB4\xD3\x73\x9F\x2A\x37", "\x4C\x5A\x4C\x55\x6C\x69\x4D\x73\x72\x53\x6F\x7A\x41\x5F\x41\x67\x74\x71\x75\x32\x4D\x41\x64\x73\x39\x28\x76\x72\x4D\x34\x44\x4B\x45\x54\x6E\x61\x37\x47\x77\x78\x38\x43\x27\x41\x5F\x73\x70\x69\x45\x6F\x45\x49\x6D\x1A\x4C\x53\...