library(tidyverse)
library(broom)
library(juanr)
library(socviz)
Models
In-class example
Here’s the code we’ll be using in class. Download it and store it with the rest of your materials for this course. If simply clicking doesn’t trigger download, you should right-click and select “save link as…”
Load libraries:
Class: trade
Fit and extract model:
# work here
= lm(exports ~ sea_borders, data = trade)
sea_model tidy(sea_model)
# A tibble: 2 × 5
term estimate std.error statistic p.value
<chr> <dbl> <dbl> <dbl> <dbl>
1 (Intercept) 8189. 1588. 5.16 2.56e- 7
2 sea_borders 8004. 468. 17.1 1.44e-64
Class: socviz
Fit and extract model:
# work here
= lm(kids ~ happy, data = gss_sm)
mod_happy tidy(mod_happy)
# A tibble: 3 × 5
term estimate std.error statistic p.value
<chr> <dbl> <dbl> <dbl> <dbl>
1 (Intercept) 2.78 NA NA NA
2 happyPretty Happy -0.110 NA NA NA
3 happyNot Too Happy 0.0374 NA NA NA