# we have to clarification of Y=A+B+(A*B) Is same or not Y=(A*B)
# Here i have taken one data set is related to cars and i assume Y is mpg as dependent
# And A is first And B is second independent variable
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
data(mtcars)
class(mtcars)
## [1] "data.frame"
d=mtcars
View(mtcars)
y=d$mpg
A=d$disp
B=d$hp
reg1=lm(y~A+B+(A*B))
reg1
##
## Call:
## lm(formula = y ~ A + B + (A * B))
##
## Coefficients:
## (Intercept) A B A:B
## 39.67426 -0.07337 -0.09789 0.00029
summary(reg1)
##
## Call:
## lm(formula = y ~ A + B + (A * B))
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.5153 -1.6315 -0.6346 0.9038 5.7030
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.967e+01 2.914e+00 13.614 7.18e-14 ***
## A -7.337e-02 1.439e-02 -5.100 2.11e-05 ***
## B -9.789e-02 2.474e-02 -3.956 0.000473 ***
## A:B 2.900e-04 8.694e-05 3.336 0.002407 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.692 on 28 degrees of freedom
## Multiple R-squared: 0.8198, Adjusted R-squared: 0.8005
## F-statistic: 42.48 on 3 and 28 DF, p-value: 1.499e-10
reg2=lm(y~(A*B))
reg2
##
## Call:
## lm(formula = y ~ (A * B))
##
## Coefficients:
## (Intercept) A B A:B
## 39.67426 -0.07337 -0.09789 0.00029
summary(reg2)
##
## Call:
## lm(formula = y ~ (A * B))
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.5153 -1.6315 -0.6346 0.9038 5.7030
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.967e+01 2.914e+00 13.614 7.18e-14 ***
## A -7.337e-02 1.439e-02 -5.100 2.11e-05 ***
## B -9.789e-02 2.474e-02 -3.956 0.000473 ***
## A:B 2.900e-04 8.694e-05 3.336 0.002407 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.692 on 28 degrees of freedom
## Multiple R-squared: 0.8198, Adjusted R-squared: 0.8005
## F-statistic: 42.48 on 3 and 28 DF, p-value: 1.499e-10
## Conclsuion: here both reg1 is Y=A+B+(A*B) is same as reg2 is Y=(A*B) it can be get
## of summary same for both regression is same hence both is same.