# r-linear mixed model with the random effect variable be continuous

Suppose there are $$N$$ subjects under study, with subject $$i$$ contribution $$n_i$$ observations, for $$i =1,...,N$$. And let $$y_{ij}$$ denote a response variable for subject $$i$$ at observation $$j$$. Let $$x_{ij}$$ denote a $$p\times 1$$ vector of predictors, and let $$z_{ij}$$ denote a $$q\times 1$$ vector of predictors. In general, the linear mixed effects model is $$y_i=X_i\alpha+Z_i\beta_i+\epsilon_i$$ where $$y_i=(y_{i1},...,y_{in_i})^T$$, $$X_i=(x_{i1}^T,...,x_{in_i}^T)^T$$, $$Z_i=(z_{i1}^T,...,z_{in_i}^T)^T$$, $$\alpha$$ is a $$p \times 1$$ vector of unknown population parameters, $$\beta_i$$ is a $$q \times 1$$ vector of unknown subject-specific random effects with $$\beta_i \sim N(0, D)$$ and the ellements of the residual vector, $$\epsilon_i$$, are $$N(0, \sigma^2I)$$.

I was trying to use the package lme4 in R which allows we to deal with the hierarchical data and consider the variability between subjects. But in this case, the data usually looks like And we can use like

lme4(frequency ~ attitude + (1|subject) + (1|scenario), data=politeness)

to specify which variable has fixed effect, attitude, and which has a random effect, the subject and scenario are two variable with random effect.

But my questions are:

1. In our example, the variable which has a random effect is $$Z_i$$. But according to the error I got when I use lme4, the level of random effect variable should be more than 1 and smaller than the number of observations. How should we deal with it when our $$Z_i$$ here is continuous?

2. We actually know the distribution of the random effect coefficients $$\beta$$, how should we using this information here? i.e. where to put the information in $$D$$?

• Random effects are used to model correlations in the outcome variable within levels of grouping variables. It is not clear from your description at which the grouping variables are. From the code you have provided it seems that you want to account for the correlations in the outcome variable frequency within subject, and also that you want to assume that measurements in the same scenario are more correlated than measurements from different scenarios in the same subject. In that case, check the last bullet point in Nested or crossed section of the GLMM FAQ.
• If you want to fix the covariance matrix of the random effects $$\beta_i$$ you should look at packages that fit kinship mixed models, e.g., the lmekin() function in the coxme package. There are also other packages available with this capability.