[R] Correct interpretation of a regression coefficient

Bendix Carstensen bend|x@c@r@ten@en @end|ng |rom reg|onh@dk
Tue Mar 10 12:23:51 CET 2026


Andrew Robinsons example merely illustrates that for numerical variables, the term x1:x2
is the same as I(x1 * x2), and x1*x2 is different from x3*x4; try:

set.seed(8675309)

example <- data.frame(x1 = rnorm(100),
                      x2 = rnorm(100))

example$x3 <- example$x1 - 1
example$x4 <- example$x2 - 1

example$y <- with(example,
                 2 * x1 + 4 * x2 + x1 * x2 + rnorm(100) * 2)
with(example, plot(x1,x3))
with(example, plot(x2,x4))

## In the following code, the statistical information about the ## interaction term is the same across the two scalings
summary(lm(y ~ x1 * x2, data = example))
summary(lm(y ~ x3 * x4, data = example))

## In the following code, the statistical information about the ## interaction term is the not same across the two scalings
summary(lm(y ~ x1 + x1:x2, data = example))
summary(lm(y ~ x3 + x3:x4, data = example))
summary(lm(y ~ x3 + I(x3*x4), data = example))
summary(lm(y ~ x1 + I(x3*x4), data = example))

with(example, plot(x1*x2, x3*x4))

________________________________


Region Hovedstaden anvender de personoplysninger, du giver os i forbindelse med din henvendelse. Du kan laese mere om form?let med anvendelsen samt dine rettigheder p? vores hjemmeside: www.regionh.dk/persondatapolitik

	[[alternative HTML version deleted]]



More information about the R-help mailing list