Re: Correct interpretation of a regression coefficient

Bendix Carstensen via R-help <[email protected]> Tue, 10 Mar 2026 11:23:51 +0000
Newsgroups gmane.comp.lang.r.general
Message-ID <AS8PR08MB9867C4505B09BED379EA637A9D46A@AS8PR08MB9867.eurprd08.prod.outlook.com>
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]]