Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to build the following model in R, however I'm quite confused about the model formulae to use to include an interaction (x1 and x2)


this intuitive formula seems to be wrong model:


is this the appropriate formula?:

y~x1*x2 ?
share|improve this question
up vote 3 down vote accepted

Basically, yes.* That formula will enter both main effects and the product term as predictors in your model. So will your first version BTW: compare lm(y~x1*x2);lm(y~x1+x2+x1*x2). For example, using set.seed(8);x1=rnorm(99);x2=rnorm(99);y=rnorm(99), either way the equation is: $$\hat Y=-.16-.02x_1-.08x_2+.09(x_1\times x_2)$$

If for some (probably improper) reason you wanted only the interaction term, you'd use x1:x2 – note this is how the interaction term is labeled in the output, not as x1*x2.

* You might want to scale your predictors to remove nonessential multicollinearity if you're interested in the standard errors of your regression coefficents or other associated statistics (including $t$s and $p$s for your predictors). This is unnecessary for the interaction term though; it only changes standard errors for the main effects. If you use y~scale(x1,T,F)*scale(x2,T,F), this will mean-center x1 and x2 but not divide by the standard deviation, thus preserving your units of measurement. If you use y~scale(x1)*scale(x2), this will standardize x1 and x2 to the scale of $Z$. Either works for controlling nonessential multicollinearity, but neither removes essential multicollinearity. For more on that, see the following reference:

Dalal, D. K., & Zickar, M. J. (2012). Some common myths about centering predictor variables in moderated multiple regression and polynomial regression. Organizational Research Methods, 15(3), 339–362. Retrieved from

share|improve this answer
thank you for your extensive answer. I'm probably gonna use a deflator anyway to reduce size effects, however as you mentioned scaling would also influence the interaction (where scaling is not necessary as i understand you). how can you circumvent this? And thank you for introducing the scale function. i was not aware of this yet. – Gritti Jul 23 '14 at 10:46
Centering doesn't influence the interaction. Standardizing (mean-centering and dividing by the SD) will change the scale of the interaction's regression coefficient (not the size, mind you; it just removes the units of measurement and places the coefficient on the scale of $\rho$), but won't change its SE or NHST statistics. – Nick Stauner Jul 23 '14 at 10:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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