Practicing Statistics Interview Questions in R
Zuzanna Chmielewska
Actuary
$$ y_i = \beta_0 + \beta_1 \cdot x_{i1} + ... + \beta_p \cdot x_{ip} + e_{i}$$ where:
$$ \hat{y_i} = \beta_0 + \beta_1 \cdot x_{i1} + ... + \beta_p \cdot x_{ip}$$
$$ \hat{y_i} = \beta_0 + \beta_1 \cdot x_{i} $$
$$ \hat{y_i} = \beta_0 + \beta_1 \cdot x_{i} $$
$$ \hat{y_i} = \beta_0 + \beta_1 \cdot x_{i} $$
$$ \hat{y_i} = \beta_0 + \beta_1 \cdot x_{i} $$
Examples: $$ \hat{y_i} = \beta_0 + \beta_1 \cdot ln(x_{i1}) + ... + \beta_p \cdot x_{ip}$$
$$ ln(\hat{y_i}) = \beta_0 + \beta_1 \cdot x_{i1} + ... + \beta_p \cdot x_{ip}$$
model <- lm(dist ~ speed, data = cars)
print(model)
Call:
lm(formula = dist ~ speed, data = cars)
Coefficients:
(Intercept) speed
-17.579 3.932
model <- lm(dist ~ speed, data = cars) new_car <- data.frame(speed = 17.5)
predict(model, newdata = new_car)
1
51.23806
model <- lm(dist ~ speed, data = cars)
plot(model)
lm()
in RPracticing Statistics Interview Questions in R