Hello all,
I have data with one categorial variable 'p'.? A binary outcome?
('result') is the result of a process determined by exactly two?
DIFFERENT levels of p.?
I am interested in the contribution of each level of p to the?
outcome of 'result'.
The code below produces a small but similar version of the dataset:
??? set.seed( 1)
??? p <- letters[1:6]
??? p1 <- sample( p, 30, replace = T)
??? p2 <- sample( p, 30, replace = T)
??? result <- runif( n = 30) > 0.7
??? x <- data.frame( p1, p2, result)
??? x <- subset( x, p1 != p2)
??? print( x, row.names = F)
If I do
?? glmer( result ~ 1 + (1|p1) + (1|p2), x, binomial)
?? ranef( fm)
... I get different conditional modes for the levels in p1 and p2,?
but this is not what I want since the condional mode of 'a' in p1?
should be the same as the conditional mode of 'a' in p2.
If I look at the random effects model matrix fm at Zt I see:
12 x 27 sparse Matrix of class "dgCMatrix"
?[1,] . . . . . . . . . 1 . . . . . . . . . . . 1 . . 1 . . #p1-a
?[2,] 1 . . . 1 . . . . . 1 1 . . . . . . . 1 . . 1 . . . . #p1-b
?[3,] . 1 . . . . . . . . . . 1 . 1 . . 1 . . . . . 1 . 1 .
?[4,] . . 1 . . . . 1 1 . . . . . . . . . . . 1 . . . . . .
?[5,] . . . . . . . . . . . . . 1 . 1 . . . . . . . . . . .
?[6,] . . . 1 . 1 1 . . . . . . . . . 1 . 1 . . . . . . . 1 #p1-f
?[7,] . . . . . . . 1 . . . . . . . 1 . . . . . . 1 1 . . . #p2-a
?[8,] . . . 1 . . . . . . . . . . . . . . . . . 1 . . 1 . . #p2-b
?[9,] 1 . 1 . . . . . . 1 . . . . . . 1 . 1 . 1 . . . . . .
[10,] . 1 . . . . . . . . . 1 1 1 . . . . . . . . . . . 1 1
[11,] . . . . 1 1 1 . 1 . 1 . . . 1 . . 1 . . . . . . . . .
[12,] . . . . . . . . . . . . . . . . . . . 1 . . . . . . . #p2-f
... while I need Zt to be more like this:
?[1,] . . . . . . . 1 . 1 . . . . . 1 . . . . . 1 1 1 1 . . # a
?[2,] 1 . . 1 1 . . . . . 1 1 . . . . . . . 1 . 1 1 . 1 . . # b
?[3,] 1 1 1 . . . . . . 1 . . 1 . 1 . 1 1 1 . 1 . . 1 . 1 . # c
?[4,] . 1 1 . . . . 1 1 . . 1 1 1 . . . . . . 1 . . . . 1 1 # d
?[5,] . . . . 1 1 1 . 1 . 1 . . 1 1 1 . 1 . . . . . . . . . # e
?[6,] . . . 1 . 1 1 . . . . . . . . . 1 . 1 1 . . . . . . 1 # f
i.e. a 6x27 with exactly two 1's in each column.
Is there a simple way/trick to obtain this?? Is the Pinheiro package?
perhaps better suited for my problem?
Any help is appreciated. Thanks in advance.
PS: The dataset is very large: it has about 2 million rows and 'p'?
has about 10000 levels. (This is the reason why I use random effects?
for p. Preferably I would use fixed?
effects.)???????????????????????????????????????????????????????????
?? ????????????????????????????????????????????????????????