Hi @akendri,
The short answer is the minus sign in a formula ignores those variables. In other words, you are dropping x2 and x4 from the model. See this below:
dd <- data.frame(
y = rnorm(100),
x1 = rnorm(100),
x2 = rnorm(100),
x3 = rnorm(100),
x4 = rnorm(100)
)
lm(y ~ x1 - x2 + x3 - x4, dd)
#>
#> Call:
#> lm(formula = y ~ x1 - x2 + x3 - x4, data = dd)
#>
#> Coefficients:
#> (Intercept) x1 x3
#> -0.05084 0.10392 0.08358
lm(y ~ x1 + x3, dd) # same as above
#>
#> Call:
#> lm(formula = y ~ x1 + x3, data = dd)
#>
#> Coefficients:
#> (Intercept) x1 x3
#> -0.05084 0.10392 0.08358
with(dd, model.matrix(y ~ x1 - x2 + x3 - x4))
#> (Intercept) x1 x3
#> 1 1 -0.95119963 0.001864079
#> 2 1 -0.77260624 -0.469920312
#> 3 1 0.31157269 0.435967828
#> [ reached getOption("max.print") -- omitted 97 rows ]
#> attr(,"assign")
#> [1] 0 1 2