0
$\begingroup$

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 enter image description here

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$?

Many thanks to any comments!

$\endgroup$
1
$\begingroup$

A couple of comments:

  • 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.
$\endgroup$
  • $\begingroup$ Thanks for the comments. The data in the table is not my question, I just gave an example about what kind of data could be modeled using the package in R. My question is can we have a random effect variable who is continuous? $\endgroup$ – Nan Jan 21 at 14:13
  • $\begingroup$ It is not exactly clear what you mean. You include random effects for specific groups in your data. Each group has its own random effects that are assumed to be continuous and normally distributed. Per group, you can have more than one random effects, e.g., an intercept and a slope. $\endgroup$ – Dimitris Rizopoulos Jan 21 at 20:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.