2024-02-04

Slide 1

Slide 2

plot_ly(Seatbelts2, x=Seatbelts2$Month, y=Seatbelts2$PetrolPrice, 
        z=Seatbelts2$DriversKilled, type='scatter3d', mode='markers', 
        color=as.factor(Seatbelts2$SeatbeltsLaw)) %>%
  layout(title = 'Drivers Killed vs Gas Price (w and w/o seatbelt law)
         between 1969 and 1984',
         scene=list(xaxis=xax, yaxis=zax, zaxis=yax))

Slide 3

Slide 4

Slide 5

ggplot(Seatbelts, aes(x=PetrolPrice, y=DriversKilled))+
  geom_point() +
  geom_smooth(method='lm') +
  labs(title='Drivers Killed vs Gas Price (w and w/o seatbelt law)
         between 1969 and 1984')

Slides 6

Slide 7

Equation for Simple Linear Regression line
\(\hat{y}=a+bx\)

where:
\(\hat{y} \text{ is the predicted value of y}\)

\(a = \overline{y}-b\overline{x}\)

\(\overline{x} = \frac{\sum x}{n}\)

\(\overline{y} = \frac{\sum y}{n}\)

\(b = \frac{Sxy}{Sxx} = \frac{\sum (x_{i}-\overline{x})(y_{i}-\overline{y})}{\sum (x_{i}-\overline{x})^{2}} = \frac{\sum (xy)-\frac{\sum x\sum y}{n}}{\sum {x}^{2}-\frac{({\sum {x})^{2}}}{n}}\)

Slide 8

Sum of the squares
\(SS = \sum x^2 - \frac{(\sum x)^2}{n}\)

Variance
\(s^{2} = \frac{\sum {x^{2}-\frac{(\sum x)^{2}}{n}}}{n-1}\)

Standard deviation
\(s = \sqrt {\frac{\sum x^2-\frac{(\sum x)^2}{n}}{n-1}}\)

Z scroes
\(Z = \frac{x-M}{s} = \frac{deiviation}{\text stand. dev.}\)