I have a dataset like this.
library(lme4)
data("sleepstudy")
head(sleepstudy)
First I create a matrix of X values.
X <- cbind(1, sleepstudy$Days)
Then I create a matrix Z
Z <- model.matrix(~ 0 + Subject + Subject:Days, data = sleepstudy)
How do I attach the model.matrix Z with matrix Z , such that the two matrices or dataframes are merged in the right manner.
Thanks.