Lecture 12 Regression Basics

Eamonn Mallon
14/10/2020

What is regression

  • statistical method you use when both the response variable and the explanatory variable are continuous variables
  • Continous variables = real numbers with decimal places – things like heights, weights, volumes, or temperatures
  • Remember in ANOVA, explanatory variables are called factors which have levels
    • sex could be a factor and has two levels (male and female)
  • Should I do ANOVA or regression?

Should I do ANOVA or regression?

  • Can you do a boxplot (ANOVA)
  • Can you do a scatterplot (Regression) plot of chunk unnamed-chunk-1

Difference between correlation and regression

  • Lots of books have very complicated explanations of this
  • Usually
    • correlation is if both x and y are random
    • regression is if you pick x (experiment)
  • But this is more of a guidline than a rule
  • I use regressions when cause and effect is important and you need the equation of the line

Equation of the line

\[ y = a + bx \]

  • y response variable
  • x explanatory variable
  • Two parameters a, the intercept and b the slope of the line. plot of chunk unnamed-chunk-2

Think back to school

plot of chunk unnamed-chunk-3

a you can read off the graph (lets say 2)

\[ b = \frac{change in y}{change in x} \] x = (9-4)/(7.5-2.5) =1

\[ y = 2 + x \]

R can do that for you

plot of chunk unnamed-chunk-4

lm(y~x)

Call:
lm(formula = y ~ x)

Coefficients:
(Intercept)            x  
          2            1  

\[ y = 2 + x \]