Edit Note: Since I posted this question, I have being suggested to read some of documents and I am still thinking on the subject. I have added some new understanding as marked between *** astriks, please do correct them if I am wrong and add remaining questions.*
I often confuse with four symbols, ":", "|", "/" and "*" in the formula, particularly while doing mixed model. Can somebody explain it clearly difference between them. I have following working example:
require(lme4)
mydata <- expand.grid(xvar1 =factor(1:10), xvar2 =factor(1:3),replication = factor(1:3))
mydata$yvar <- rnorm(nrow(mydata), 10, 5)
fm1 <- lmer(yvar ~ 1 + (1|xvar1) + (1|xvar2) + (1|xvar1:xvar2), mydata)
***My understanding: Cross classification between xvar1, xvar2***
fm2 <- lmer(yvar ~ 1 + (1|xvar1) + (1|xvar2) + (1|xvar1/xvar2), mydata)
***is not correct model, should remove 1|xvar1, 1|xvar2***
***** has fixed intercept 1 , I do not know if it correct technically**
**fm2 <- lmer(yvar ~ 1 + (1|xvar1/xvar2), mydata)*****
*is xvar1 is nested in xvar2 and is essentially same as fm1*
fm3 <- lmer(yvar ~ 1 + (1|xvar1) + (1|xvar2) + (xvar1|xvar2), mydata)
Warning message:
In mer_finalize(ans) : singular convergence (7)
***I do not have idea on "|",***
fm4 <- lmer(yvar ~ 1 + (1|xvar1) + (1|xvar2) + xvar1:xvar2, mydata)
Error in mer_finalize(ans) : Downdated X'X is not positive definite, 31 ;
***xvar1:xvar2 interaction term, technically correct !***
fm5 <- lmer(yvar ~ 1 + (1|xvar1) + (1|xvar2) + (1|xvar1*xvar2), mydata)
Error in validObject(.Object) :
invalid class "ngTMatrix" object: all row indices must be between 0 and nrow-1
In addition: Warning message:
In Ops.factor(xvar1, xvar2) : * not meaningful for factors
**again (1|xvar1) and (1|xvar2) are not necessary**
***fm5 <- lmer(yvar ~ 1 + (1|xvar1*xvar2), mydata) is equal to***
***fm5 <- lmer(yvar ~ 1 + (1|xvar1) + (1|xvar2)+ (1|xvar1*xvar2)***
fm6 <- lmer(yvar ~ 1 + (1|xvar1) + (1|xvar2) + (xvar1/xvar2), mydata)
***same as fm2***
fm7 <- lmer(yvar ~ 1 + (1|xvar1) + (1|xvar2) + (0 + xvar1|xvar2), mydata)
Warning message:
In mer_finalize(ans) : singular convergence (7)
***I have no idea on xvar1|xvar2, 0 means no intercept I believe***
Edits: Here is something I learned from R documentation on linear model formula
(1) yvar ~ xvar1 + xvar2 + xvar1:xvar2 - cross over classification
is same as yvar ~ xvar1 * xvar2
(2) yvar ~ xvar1 / xvar2 - nested classification (
however means xvar1 + xvar2 + xvar1:xvar2)
is same as yvar ~ xvar1 %in% xvar2
I am not sure these applicable to lm model holds true for mixed model.
I am still not on track on use of "|" which is I believe unique in mixed models.