1
$\begingroup$

I'm running a generalized linear model with a dichotomous dependent variable, 2 two-level factor variables, 1 two-level sample variable, and 4 performance measurements (see below for a brief description).

  • dichotomous dependent variable: accurate/failed response (0/1)
  • 2 two-level factor variables: type of presentation (pics/no pics) type of question (open/alternatives)
  • 1 two-level sample variable: two samples from two different populations (high/low socioeconomic status)
  • performance measurements: math ability, working memory, numeracy and fluid intelligence.

This is a repeated measure study where participants solve 4 problems: 2 type of presentation * 2 type of question

I am interested in seeing if:

  • performance improves with any of the 2 two-level factor variables (and combinations) after controlling for the ability of the participants solving my problems (performance measurements).
  • do the changes mentioned above depend on the population? (two-level sample variable) e.g. does low socioeconomic benefit more from pics and alternatives question?

Currently I've tried with the following code in R:

 model <- glmer(accuracy_measure ~ 2_levels_var_1 * 2_levels_var_2 * 2_levels_sample_var + performance_var_1 + performance_var_2 + performance_var_3 + performance_var_4, data = data_df, family = "binomial")

I've had done some research (ref_1, ref_2, ref_3 and ref_4) and I think I have some or minimum understanding of contrast setting. So to set the contrasts I use the following lines (before running the model):

contrasts(data_df$2_levels_var_1) <- contr.sdif
contrasts(data_df$2_levels_var_2) <- contr.sdif

About this, I'm not sure what kind of comparison I'm setting (e.g. level 1 against level 2, setting one level as the baseline, etc.). Also, I'm not quite sure if is enough to set the contrasts in the variables or if is it necessary to add some argument to the summary of the model, or in the model itself (e.g. glmer(..., contrasts = ...).

On the other hand, I need to define some random effects associated to the subjects and to the items they respond. I think this is achievable by adding these arguments to the formula:

(1 | ID): random variance associated with participants
(1 | item_id): random variance associated with items

So the original model would take this form:

model <- glmer(accuracy_measure ~ 2_levels_var_1 * 2_levels_var_2 * 2_levels_sample_var + performance_var_1 + performance_var_2 + performance_var_3 + performance_var_4 + (1|ID) + (1|item_id), data = data_df, family = "binomial")

To recap:

- Is this the proper way to set the contrasts?

- Is it necessary to add an argument to the glmer() or summary() function to set the contrasts?

- Is this the proper way to set random effects?

- Should I start from a more complex model that would include all or some of the IV interactions in the random effects? ( 2_levels_var_1 / 2_levels_var_2 / 2_levels_sample_var | ID) + ( 2_levels_var_1 / 2_levels_var_2 / 2_levels_sample_var | item_id)?

$\endgroup$

Your Answer

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

Browse other questions tagged or ask your own question.