简体   繁体   中英

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?

您可以只使用:运算符代替*

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM