[英]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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.