0
$\begingroup$

I am estimating a random intercept and a random slope model using the following R code. My dependent and independent variable are both continuous.

randominterceptfixedslope<-lmer(y ~ x + (1|state),data=data,method="ML") # model with fixed slope but random intercept
randominterceptrandomslope<-lmer(y ~ x + (1+x|state),data=data,method="ML") # model with random slope and random intercept

anova(randominterceptfixedslope,randominterceptrandomslope)

Anova tells me that my randominterceptrandomslope model is a better fit on the data. So far good, please correct me if I am wrong.

My question is: If I have another independent variable $x_1$, can I put two independent variables in the above model i.e. can I have a randominterceptfixedslope and randominterceptrandomslope model with two independent variables. If yes, how do I do that? As in what the code should look like?

Thanks for your response. I got a second query. lets say my full model is this:

     randominterceptrandomslope<-lmer(y ~ x1 + x2 + x3 + x4 (1+x1+x2+x3+x4|state),data=data,method="ML")

If some of my independent variables are correlated, what is the procedure of reducing the collinearity issue in a linear mixed effect model? I could spot collinerity using VIF and retain the most significant independent variables but I can do this for each factor level (levels of state) individually. But won't it result in retaining some independent variables in one factor level while deleting the same in other factor level? I guess the main question is how to spot collinearity in a mixed effect model and what to do with it when you have 5 or 6 independent variables?

$\endgroup$
0

1 Answer 1

6
$\begingroup$

In linear mixed effects mode, definitely you can include more than one independent variable. The general linear mixed model has the form

$y_i=X_i \beta + Z_i bi + \epsilon_i$

where $b_i\sim N(0,D)$, $\epsilon_i\sim N(0,I_{n_i} \sigma^2)$, $X_i$ and $Z_i$ are the known design matrices for fixed($\beta's$) and random effects regression coefficients($bi's$) respectively. $I_{n_i}$ is the $n_i$ dimensional identity matrix and $D$ is the variance co-variance matrix of $b_i$.

So you can include as many independent variable you need in the model and also the random component. But you should be concerned that as you increase the dimension of random effects, the estimation procedure becomes more complex as $b_i$'s are unobserved and so does their variance covariance matrix $D$.

The R codes are as follows

randominterceptfixedslope<-lmer(y ~ x1 + x2 + (1|state),data=data,method="ML") 
randominterceptrandomslope<-lmer(y ~ x1 + x2 + (1+x1+x2|state),data=data,method="ML")

Its not always the same set of covariate contribute both as fixed and random component. That means you can also think of the following model

randominterceptrandomslope<-lmer(y ~ x1 + x2 + (1+x1|state),data=data,method="ML")

or

randominterceptrandomslope<-lmer(y ~ x1 + x2 + (1+x2|state),data=data,method="ML")

You better use xyplot under lattice to see which covariate can be served in the random component.

$\endgroup$
2
  • $\begingroup$ thanks a lot for your reply. But if I have collinearity in my independent variables, how to account for it in a lmer. I have edited my question to include this $\endgroup$ Jul 7, 2014 at 19:28
  • 1
    $\begingroup$ @user3013423: Probably a good idea to ask it in a separate question. $\endgroup$ Jul 7, 2014 at 20:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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