September 2019

height = intercept + 0.2 back + error

Data plots

across ~~ back

height ~ across

height ~ back

Model fit

height ~ across

## 
## Call:
## lm(formula = height ~ across, data = dat)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.83664 -0.28953 -0.02315  0.34661  0.67719 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  3.03626    0.16433  18.477   <2e-16 ***
## across      -0.02034    0.03617  -0.562    0.579    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.3859 on 26 degrees of freedom
## Multiple R-squared:  0.01201,    Adjusted R-squared:  -0.02599 
## F-statistic: 0.3162 on 1 and 26 DF,  p-value: 0.5787

height ~ back

## 
## Call:
## lm(formula = height ~ back, data = dat)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.35187 -0.10475 -0.00006  0.08290  0.36428 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   2.2412     0.0833  26.907  < 2e-16 ***
## back          0.1583     0.0168   9.419 7.26e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.1848 on 26 degrees of freedom
## Multiple R-squared:  0.7734, Adjusted R-squared:  0.7646 
## F-statistic: 88.72 on 1 and 26 DF,  p-value: 7.262e-10

height ~ across + back

## 
## Call:
## lm(formula = height ~ across + back, data = dat)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.33980 -0.09659 -0.01603  0.07463  0.39512 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  2.29287    0.11290  20.309  < 2e-16 ***
## across      -0.01203    0.01752  -0.686    0.499    
## back         0.15768    0.01700   9.275 1.43e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.1868 on 25 degrees of freedom
## Multiple R-squared:  0.7775, Adjusted R-squared:  0.7598 
## F-statistic: 43.69 on 2 and 25 DF,  p-value: 6.925e-09

Correlated predictors

height = intercept + 0.2 back + error

across ~~ back

height ~ across

## 
## Call:
## lm(formula = height ~ across, data = dat)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.31673 -0.19924  0.00421  0.18760  0.40666 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  1.82617    0.11672  15.646 1.58e-11 ***
## across       0.16923    0.02255   7.505 8.62e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.2372 on 17 degrees of freedom
## Multiple R-squared:  0.7681, Adjusted R-squared:  0.7545 
## F-statistic: 56.32 on 1 and 17 DF,  p-value: 8.619e-07

height ~ back

## 
## Call:
## lm(formula = height ~ back, data = dat)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.26514 -0.17160 -0.00382  0.12265  0.50857 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  1.86453    0.09906  18.822 8.05e-13 ***
## back         0.20887    0.02441   8.558 1.44e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.2138 on 17 degrees of freedom
## Multiple R-squared:  0.8116, Adjusted R-squared:  0.8005 
## F-statistic: 73.24 on 1 and 17 DF,  p-value: 1.441e-07

height ~ across + back

## 
## Call:
## lm(formula = height ~ across + back, data = dat)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.28478 -0.13676 -0.01669  0.13845  0.46326 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  1.82624    0.10465  17.450 7.75e-12 ***
## across       0.05774    0.05315   1.086   0.2934    
## back         0.14475    0.06382   2.268   0.0375 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.2127 on 16 degrees of freedom
## Multiple R-squared:  0.8245, Adjusted R-squared:  0.8026 
## F-statistic:  37.6 on 2 and 16 DF,  p-value: 8.98e-07

Correlated predictors both have effect

height = intercept - 0.1 across + 0.2 back + error

## 
## Call:
## lm(formula = height ~ across + back, data = dat)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.3297 -0.1351  0.0006  0.1400  0.4394 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  2.88032    0.10522  27.376  < 2e-16 ***
## across      -0.09561    0.03123  -3.062  0.00592 ** 
## back         0.21396    0.04203   5.091 4.83e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.2183 on 21 degrees of freedom
## Multiple R-squared:  0.5787, Adjusted R-squared:  0.5386 
## F-statistic: 14.42 on 2 and 21 DF,  p-value: 0.0001143

height ~ back

## 
## Call:
## lm(formula = height ~ back, data = dat)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.44287 -0.18645  0.00447  0.16497  0.54240 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  2.74657    0.11247  24.421  < 2e-16 ***
## back         0.11077    0.02949   3.756  0.00109 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.2565 on 22 degrees of freedom
## Multiple R-squared:  0.3907, Adjusted R-squared:  0.363 
## F-statistic:  14.1 on 1 and 22 DF,  p-value: 0.001093

height ~ across

## 
## Call:
## lm(formula = height ~ across, data = dat)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.57880 -0.14808 -0.00289  0.11644  0.64591 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  2.95954    0.15197  19.475 2.32e-15 ***
## across       0.03191    0.02724   1.171    0.254    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.3188 on 22 degrees of freedom
## Multiple R-squared:  0.05871,    Adjusted R-squared:  0.01592 
## F-statistic: 1.372 on 1 and 22 DF,  p-value: 0.254

Interactions between continuous variables

Data plot

height ~ across \(*\) back

height ~ poly(across,2) + poly(back,2) + across:back

Multicolinearity

Data plot

height ~ across + back

Summary

  • Linear models fit planes (and hyper-planes).
  • As do generalised linear and mixed models.
  • Planes allow you interpret the effect of each predictor while holding constant and controlling for other variables, because of their geometry.
  • No matter what level of the first variable you choose, the response will change by the same amount when you change the second variable. E.g no matter how far across you are, the effect of going one row back is the same.
  • If you don’t control for correlated predictors, your inference (relationships) will be biased (wrong)
  • Interactions change the interpretation, we still controlling for the other variables, but we can’t interpret effects holding constant other variables.
  • If including interactions between continuous variable, include polynomial terms so the geometry doesn’t stuff up.
  • Multicolinearity stuffs thing up, but only when data is very highly correlated.