Skip to content

Instantly share code, notes, and snippets.

@svmiller
Last active April 29, 2021 01:10
Show Gist options
  • Save svmiller/3b0a0b79d5753ee1eeca506b1aa7762e to your computer and use it in GitHub Desktop.
Save svmiller/3b0a0b79d5753ee1eeca506b1aa7762e to your computer and use it in GitHub Desktop.
"Famous Five" Example... something to riff on for later
set.seed(8675309)
tibble(age = round(runif(25,18,80)),
e = rnorm(25,0,5),
approval = round(1.25*age + e)) -> Dat
Dat %>%
ggplot(.,aes(age, approval)) +
geom_point()
summary(M1 <- lm(approval ~ age, data=Dat))
Dat %>%
summarize(sum_approval = sum(approval),
sum_approval2 = sum(approval^2),
sum_age = sum(age),
sum_age2 = sum(age^2),
sum_prod = sum(age*approval)) %>%
gather()
XY <- cbind(1,Dat$age,
Dat$approval)
t(XY) %*% XY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment