0

I understand that * means that we check for the association between two predictor variables and + means that we add another predictor variable to the model we already have. But how do I write a function (lm) for the following question: Variable A (dependent variable) shall be impacted by variable B (predictor variable) and variable C. How does C -moderate B, how do both B and C directly impact A, how does the association between B and C impact A and how is all this moderated by the variables D and E?

Variables A until D are all continuous variables that are about personal characters, variable E is gender (male / female). A part of the formula should look like this:

M1 <- lm(A ~ B_centered * C_centered .....   * gender, data = data) 

The middle of the equation is complicated, because it stays unclear to me when to use * and + and how I need to connect the single calculations which each other and if * is used for both the correlations as well as for the moderation.

Sorry if the question sounds strange I am new to R! Thank you for reading and trying to help.

I tried to find a way to connect the single terms of the formula to each other, but got confused. I listed the single interactions and calculations that need to be performed in the model one by one. Searched google, youtube etc. I put gender at the end as last independent variable in the formula and variable A as dependent variable and I put the two single independent variables B and C in. What is missing are the interactions and moderations between the independent variables and variable D.

Phil
  • 7,287
  • 3
  • 36
  • 66
  • 2
    Your understanding of the meaning of R formula operators is incorrect. Read https://meta.stackoverflow.com/q/334822 and post a [MCVE] if you want to participate in StackOverflow in the manner that is expected. – IRTFM Feb 09 '23 at 03:07

0 Answers0