StatQuest: Linear Regression (aka GLMs, part 1)

Linear regression is the first part in a bunch of videos I’m going to do about General Linear Models.

I also made a companion StatQuest that shows how to do linear regression in R:

Here’s the code from the video if you want to try it out yourself:

## Here's the data from the example: <- data.frame(
  weight=c(0.9, 1.8, 2.4, 3.5, 3.9, 4.4, 5.1, 5.6, 6.3),
  size=c(1.4, 2.6, 1.0, 3.7, 5.5, 3.2, 3.0, 4.9, 6.3)) # print the data to the screen in a nice format

## plot a x/y scatter plot with the data

## create a "linear model" - that is, do the regression
mouse.regression <- lm(size ~ weight,
## generate a summary of the regression

## add the regression line to our x/y scatter plot
abline(mouse.regression, col="blue")

One thought on “StatQuest: Linear Regression (aka GLMs, part 1)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s