- Instead of one regressor, we can have multiple ones.
For example, how do horse power (hp) and weight (wt) relate to miles per gallon? \[ mpg_i = b_0 + b_1 hp_i + b_2 wt_i + e_i \]
Well, how?
2018-10-05
For example, how do horse power (hp) and weight (wt) relate to miles per gallon? \[ mpg_i = b_0 + b_1 hp_i + b_2 wt_i + e_i \]
Well, how?
Do this!
lm(formula = mpg ~ wt + hp, data = mtcars)
wt_plus
defined as wt + 1
above.wt_plus
wouldn’t add any information - hence it’s redundantx
, this translates into \(Var(x)\neq0\).Caschool
dataset.testscr
also depend on average income in the school area? \[
\text{testscr}_i = b_0 + b_1 \text{str}_i + b_2 \text{avginc}_i + e_i
\]We simply add avginc
to our formula
:
library("Ecdat") # reload the data fit_multivariate <- lm(formula = "testscr ~ str + avginc", data = Caschool) summary(fit_multivariate)
str
dependent on avginc
? Is the effect stronger in richer areas?CPS1988
library(ScPoEconometrics) runTutorial("lm-example")