Last active
April 29, 2021 01:10
-
-
Save svmiller/3b0a0b79d5753ee1eeca506b1aa7762e to your computer and use it in GitHub Desktop.
"Famous Five" Example... something to riff on for later
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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