Student Name1, Student Name2
"2017-08-22"
We are interested in public safety. Specifically, we focused on traffic flow.
str(cars)
'data.frame': 50 obs. of 2 variables:
$ speed: num 4 4 7 7 8 9 10 10 10 11 ...
$ dist : num 2 10 4 22 16 10 18 26 34 17 ...
library(tidyverse)
cars2 <- cars %>%
dplyr::mutate(kmh = speed*1.6, meters = dist*.3 )
head(cars2, n=5)
speed dist kmh meters
1 4 2 6.4 0.6
2 4 10 6.4 3.0
3 7 4 11.2 1.2
4 7 22 11.2 6.6
5 8 16 12.8 4.8
summarize(cars2, mean(dist), mean(speed))
mean(dist) mean(speed)
1 42.98 15.4
summarize(cars2, mean(kmh), mean(meters))
mean(kmh) mean(meters)
1 24.64 12.894
model1.lm <- lm(dist ~ speed, data = cars2)
model2.lm <- lm(meters ~ kmh, data = cars2)
library(arm)
display(model1.lm)
lm(formula = dist ~ speed, data = cars2)
coef.est coef.se
(Intercept) -17.58 6.76
speed 3.93 0.42
---
n = 50, k = 2
residual sd = 15.38, R-Squared = 0.65
library(arm)
display(model2.lm)
lm(formula = meters ~ kmh, data = cars2)
coef.est coef.se
(Intercept) -5.27 2.03
kmh 0.74 0.08
---
n = 50, k = 2
residual sd = 4.61, R-Squared = 0.65
library(lm.beta)
lm.beta(model.lm)
Call:
lm(formula = dist ~ speed, data = cars2)
Standardized Coefficients::
(Intercept) speed
0.0000000 0.8068949
Call:
lm(formula = meters ~ kmh, data = cars2)
Standardized Coefficients::
(Intercept) kmh
0.0000000 0.8068949