20 nov 2018

## Multiple regression

$\LARGE{\text{outcome} = \text{model} + \text{error}}$

In statistics, linear regression is a linear approach for modeling the relationship between a scalar dependent variable y and one or more explanatory variables denoted X.

$\LARGE{Y_i = \beta_0 + \beta_1 X_{1i} + \beta_2 X_{2i} + \dotso + \beta_n X_{ni} + \epsilon_i}$

In linear regression, the relationships are modeled using linear predictor functions whose unknown model parameters $$\beta$$'s are estimated from the data.

Source: wikipedia

## Outcome vs Model

error = c(2, 1, .5, .1)
n = 100

layout(matrix(1:4,1,4))
for(e in error) {

x = rnorm(n)
y = x + rnorm(n, 0 , e)

r   = round(cor(x,y), 2)
r.2 = round(r^2, 2)

plot(x,y, las = 1, ylab = "outcome", xlab = "model", main = paste("r =", r," r2 = ", r.2), ylim=c(-2,2), xlim=c(-2,2))
fit <- lm(y ~ x)
abline(fit, col = "red")

}