Skip to content

Instantly share code, notes, and snippets.

@ryanburge
Last active April 17, 2017 20:27
Show Gist options
  • Save ryanburge/d56b1d2b490d86c5e51ee4bdf9396687 to your computer and use it in GitHub Desktop.
Save ryanburge/d56b1d2b490d86c5e51ee4bdf9396687 to your computer and use it in GitHub Desktop.
Class Instructions for 3/29/2017 - Regression
## RUN ALL THIS SYNTAX BEFORE WE START
## This will install and load all the packages you need for class today.
ipak <- function(pkg){
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if (length(new.pkg))
install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}
packages <- c("ggplot2", "dplyr", "car", "highcharter", "ggcorrplot", "dwplot")
ipak(packages)
## STOP AND WAIT
## Take a look at this dataset
## Here's the data link:
df <- read.csv(url("https://raw.githubusercontent.com/ryanburge/pls2003_sp17/master/living.csv"))
## Let's start by finding comparing height and weight again.
## Now we need to start adding variables for control purposes.
## Let's talk about the logic of regression analysis.
## Let's visualize it.
## Here's the syntax for a regression
reg1 <- lm(DV ~ IV + IV + IV + IT, data = NAME OF THE DATASET)
summary(reg1)
dwplot(reg1) + geom_vline(xintercept = 0, colour = "grey50", linetype = 2)
### P-Hacking!!
https://fivethirtyeight.com/features/science-isnt-broken/#part1
Here's the data link:
simon <- read.csv(url("http://goo.gl/exQA14"))
Here's the link to the codebook:
http://opensiuc.lib.siu.edu/cgi/viewcontent.cgi?article=1010&context=ppi_statepolls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment