What is your question?
What model of the world matches your question?
Is your model valid?
Query your model to answer your question.
What is regression?
What do regression coefficients mean?
What do the error coefficients of a regression mean?
Correlation and Regression
Transformation and Model Structure for More Sensible Coefficients
y = a + bx + error
y = a + bx + error
This is 90% of the modeling you will ever do because...
y = a + bx + error
This is 90% of the modeling you will ever do because...
Everything is a linear model!
multiple parameters (x1, x2, etc...)
nonlinear transformations of y or x
multiplicative terms (b x1 x2) are still additive
generalized linear models with non-normal error
and so much more....
yi=β0+β1xi+ϵi
ϵi∼i.i.d.N(0,σ)
Then it’s code in the data, give the keyboard a punch
Then cross-correlate and break for some lunch
Correlate, tabulate, process and screen
Program, printout, regress to the mean
-White Coller Holler by Nigel Russell
Classic style:
yi=β0+β1xi+ϵi ϵi∼N(0,σ)
Classic style:
yi=β0+β1xi+ϵi ϵi∼N(0,σ)
Prediction as Part of Error:
^yi=β0+β1xi yi∼N(^yi,σ)
Classic style:
yi=β0+β1xi+ϵi ϵi∼N(0,σ)
Prediction as Part of Error:
^yi=β0+β1xi yi∼N(^yi,σ)
Matrix Style: Y=Xβ+ϵ
What is regression?
What do regression coefficients mean?
What do the error coefficients of a regression mean?
Correlation and Regression
Transformation and Model Structure for More Sensible Coefficients
Association
Association
Prediction
Association
Prediction
Counterfactual
term | estimate | std.error |
---|---|---|
(Intercept) | 6.567 | 0.791 |
inbreeding.coefficient | -11.447 | 3.189 |
term | estimate | std.error |
---|---|---|
(Intercept) | 6.567 | 0.791 |
inbreeding.coefficient | -11.447 | 3.189 |
Association: A one unit increase in inbreeding coefficient is associated with ~11 fewer pups, on average.
Prediction: A new wolf with an inbreeding coefficient 1 unit greater than a second new wolf will have ~11 fewer pups, on average.
Counterfactual: If an individual wolf had had its inbreeding coefficient 1 unit higher, it would have ~11 fewer pups.
Association: A one unit increase in inbreeding coefficient is associated with ~11 fewer pups, on average.
Prediction: A new wolf with an inbreeding coefficient 1 unit greater than a second new wolf will have ~11 fewer pups, on average.
Counterfactual: If an individual wolf had had its inbreeding coefficient 1 unit higher, it would have ~11 fewer pups.
term | estimate | std.error |
---|---|---|
(Intercept) | 6.567 | 0.791 |
inbreeding.coefficient | -11.447 | 3.189 |
term | estimate | std.error |
---|---|---|
(Intercept) | 6.567 | 0.791 |
inbreeding.coefficient | -11.447 | 3.189 |
When the inbreeding coefficient is 0, a wolves will have ~6.6 pups, on average.
What is regression?
What do regression coefficients mean?
What do the error coefficients of a regression mean?
Correlation and Regression
Transformation and Model Structure for More Sensible Coefficients
Fit error - error due to lack of precision in estimates
Residual error - error due to variability not explained by X.
term | estimate | std.error |
---|---|---|
(Intercept) | 6.567 | 0.791 |
inbreeding.coefficient | -11.447 | 3.189 |
term | estimate | std.error |
---|---|---|
(Intercept) | 6.567 | 0.791 |
inbreeding.coefficient | -11.447 | 3.189 |
Shows precision of ability to estimate coefficients
Gets smaller with bigger sample size!
Remember, ~ 2 SE covered 95% CI
Comes from likelihood surface...but we'll get there
r.squared | sigma |
---|---|
0.369 | 1.523 |
ϵi∼N(0,σ)
How much does does # of pups vary beyond the relationship with inbreeding coefficient?
For any number of pups estimated on average, ~68% of the # of pups observed will fall within ~1.5 of that number
r.squared | sigma |
---|---|
0.369 | 1.523 |
R2=1−σ2residualσ2y
Fraction of the variation in Y related to X.
Here, 36.9% of the variation in pups is related to variation in Inbreeding Coefficient
Relates to r, the Pearson correlation coefficient
What is regression?
What do regression coefficients mean?
What do the error coefficients of a regression mean?
Correlation and Regression
Transformation and Model Structure for More Sensible Coefficients
Describes the relationship between two variables. Not scaled.
Describes the relationship between two variables. Not scaled.
σxy = population level covariance
sxy = covariance in your sample
Describes the relationship between two variables. Not scaled.
σxy = population level covariance
sxy = covariance in your sample
σXY=∑(X−ˉX)(y−ˉY)n−1
Describes the relationship between two variables. Not scaled.
σxy = population level covariance
sxy = covariance in your sample
σXY=∑(X−ˉX)(y−ˉY)n−1
Describes the relationship between two variables.
Scaled between -1 and 1.
ρxy = population level correlation, rxy = correlation in
your sample
Y is perfectly predicted by X if r = -1 or 1.
R2 = the porportion of variation in y explained by x
Covariance Matrix:
inbreeding.coefficient pupsinbreeding.coefficient 0.01 -0.11pups -0.11 3.52
Covariance Matrix:
inbreeding.coefficient pupsinbreeding.coefficient 0.01 -0.11pups -0.11 3.52
Correlation Matrix:
inbreeding.coefficient pupsinbreeding.coefficient 1.00 -0.61pups -0.61 1.00
Covariance Matrix:
inbreeding.coefficient pupsinbreeding.coefficient 0.01 -0.11pups -0.11 3.52
Correlation Matrix:
inbreeding.coefficient pupsinbreeding.coefficient 1.00 -0.61pups -0.61 1.00
Yes, you can estimate a SE (cor.test()
or bootstrapping)
b=sxys2x =cov(x,y)var(x)
b=sxys2x =cov(x,y)var(x)
=rxysysx
zi=xi−ˉxσx
When we z-transform variables, we put them on the same scale
The covariance between two z-transformed variables is their correlation!
z(yi)=β0+β1z(xi)+ϵi
term | estimate | std.error |
---|---|---|
(Intercept) | 0.000 | 0.166 |
inbreeding_std | -0.608 | 0.169 |
versus correlation: -0.608
What is regression?
What do regression coefficients mean?
What do the error coefficients of a regression mean?
Correlation and Regression
Transformation and Model Structure for More Sensible Coefficients
Many times X = 0 is silly
E.g., if you use year, are you going to regress back to 0?
Centering X allows you to evaluate a meaningful intercept
xi centered=xi−mean(x)
term | estimate | std.error |
---|---|---|
(Intercept) | 3.958 | 0.311 |
inbreeding.centered | -11.447 | 3.189 |
Intercept implies wolves with the average level of inbreeding in this study have ~4 pups. Wolves with higher inbreeding have fewer pups, wolves with lower inbreeding have more.
Often, Y cannot be negative
And/or the process generating Y is multiplicative
Log(Y) can fix this and other sins.
VERY common, but, what do the coefficients mean?
log(yi)=β0+β1xi+ϵi
term | estimate | std.error |
---|---|---|
(Intercept) | 1.944 | 0.215 |
inbreeding.coefficient | -2.994 | 0.869 |
term | estimate | std.error |
---|---|---|
(Intercept) | 1.944 | 0.215 |
inbreeding.coefficient | -2.994 | 0.869 |
exp(-2.994)-1 = -0.95, so, a 1 unit increase in x causes y to lose 95% of its value, so...
term | estimate | std.error |
---|---|---|
(Intercept) | 1.944 | 0.215 |
inbreeding.coefficient | -2.994 | 0.869 |
exp(-2.994)-1 = -0.95, so, a 1 unit increase in x causes y to lose 95% of its value, so...
Association: A one unit increase in inbreeding coefficient is associated with having 95% fewer pups, on average.
(sensu Richard McElreath)
What is your question?
What model of the world matches your question?
Is your model valid?
Query your model to answer your question.
Keyboard shortcuts
↑, ←, Pg Up, k | Go to previous slide |
↓, →, Pg Dn, Space, j | Go to next slide |
Home | Go to first slide |
End | Go to last slide |
Number + Return | Go to specific slide |
b / m / f | Toggle blackout / mirrored / fullscreen mode |
c | Clone slideshow |
p | Toggle presenter mode |
t | Restart the presentation timer |
?, h | Toggle this help |
Esc | Back to slideshow |