Adding/removing covariates in lmer?

Viewed 45

I am trying to add covariates in lmer, but I do have difficulty with figuring that that, can anyone help me out with this?

I have this happy_plot = lmer(happy_score ~ life_quality +(1|subject), data) as my original code with no covariates. My question is what should I do if I want to add age, gender, SES, edu level as covariates of no interest into the code. Should it be happy_plot = lmer(happy_score ~ life_quality + age + gender + edu_level + SES + (1|subject),data)?

Another question is what is the argument "contrasts" means? I couldn't really figure it out by reading the R Documentation.

1 Answers

The syntax you used does include the additional variables in the model, but please do see my comment above, as it was not clear to me what you meant by "covariates of no interest". The contrasts define the kind of comparisons that you can make from the model. By default, i.e. if you leave that argument as NULL, you will get whatever contrasts are defines under options. See here for more details: https://www.rdocumentation.org/packages/stats/versions/3.6.2/topics/contrasts. If you use the comand

options("contrasts")

in the command line you can check what is being used in your system. I suspect you do not really want to touch that given you seem to be just starting on fitting models in lmer. But if you want to know more about them, here's a Tag info for them: https://stats.stackexchange.com/tags/contrasts/info. Being a tag it means you can easily search stack for questions and answers on them.

Related