user1612119
user1612119

Reputation: 3

In R: How do I run a multiple linear regression on interacted predictors without regressing on the variables not interacted?

For the life of me I cannot figure out how to run a multiple linear regression with two predictors interacted without also regressing on the interacted predictors by themselves. Here is an example:

When I use this script to do a regression

lagfit <- lm(formula = Production ~ DayOfWeek*Employees, data = train)

It returns a regression with three predictors: day of week, # of employees, and the interaction. But I only want to regress on the interaction. How can I do this?

Upvotes: 0

Views: 339

Answers (1)

smillig
smillig

Reputation: 5351

You can just use the : operator instead of *:

lagfit <- lm(formula = Production ~ DayOfWeek:Employees, data = train)

Upvotes: 1

Related Questions