Transitioning from HLM (program) to R for Multilevel Modeling - Help!

Hello! Thank you for reading and a big thank you if you can help.

My goal is to successfully run this type of model in R. I know how to set up the dataset and interpret the results using HLM (the program) but I am completely lost when trying to get it into R.

Screenshot of the model is attached.

Right now, for the level 1 dataset I have 4 observations for each subject and for the level 2 dataset I have subject sex as the only variable.

I have a dependent variable that is predicted by two categorical variables (dummy coded - var 1 and var 2) and their interaction (var 3). I'm controlling for subject sex in level 2.

In HLM, what I would do is run the model with var 1 (dummy coded as -0.5 and 0.5) and var 2 (dummy coded as -0.5 and 0.5) and the interaction. If the interaction is significant, I would look for simple effects by recentering var 1 to 0 and 1 and getting a new interaction term. And then running a third model with var 1 as -1 and 0 and the new interaction term.

How would I do this in R?


1) How do I need to construct the datasets to import the data. (Currently have 2 datasets in SPSS for level 1 and level 2).

2) How do I write the syntax for the original model in R?

3) How do I probe the interaction in R? Do I need to pre-create all of the variables I may be interested in or is there a way to do this in R?

The only thing I know to do right now is a model that looks like this:

example <- lmer(DV ~ IV1 + IV2 + IV3 + (1 | GROUP), data = exampledata)

I would greatly appreciate any help!

Thank you!
I did this:

hlm <- lmer(dv ~ iv1cent + iv2cent + iv1iv2 + subsex + (1 | id), data = data)

However, I'm supposed to start applying Bayesian things to multilevel models tomorrow and I don't understand what all of the parts of the command are. I did run the same basic dataset in both HLM and R and got the same values for the coefficients and standard errors.

What is happening in the parentheses?


Less is more. Stay pure. Stay poor.
I don't know either but wanted to figure it out. I was thinkinking 1 represented random slope and pipe then random group.