Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between the interaction : and * term for formulas in StatsModels OLS regression

Hi I'm learning Statsmodel and can't figure out the difference between : and * (interaction terms) for formulas in StatsModels OLS regression. Could you please give me a hint to figure this out?

Thank you!

The documentation: http://statsmodels.sourceforge.net/devel/example_formulas.html

like image 717
user3368526 Avatar asked Oct 10 '15 03:10

user3368526


People also ask

What is an interaction term in regression?

In regression, an interaction effect exists when the effect of an independent variable on a dependent variable changes, depending on the value(s) of one or more other independent variables.

Why would you use an interaction term in a regression?

Why include an interaction term? A model without interactions assumes that the effect of each predictor on the outcome is independent of other predictors in the model.

What does interaction mean in multiple regression?

Interaction: An interaction occurs when an independent variable has a different effect on the outcome depending on the values of another independent variable.

Can linear regression have interaction terms?

Interaction terms are sometimes added to linear regression models when the effect of one variable depends on the value of another variable.


1 Answers

":" will give a regression without the level itself. just the interaction you have mentioned.

"*" will give a regression with the level itself + the interaction you have mentioned.

for example

a. GLMmodel = glm("y ~ a: b" , data = df)

you'll have only one independent variable which is the results of "a" multiply by "b"

b. GLMmodel = glm("y ~ a * b" , data = df)

you'll have 3 independent variables which is the results of "a" multiply by "b" + "a" itself + "b" itself

like image 165
Yaron Avatar answered Oct 02 '22 14:10

Yaron