2025-09-07
xax = list(title = "Murder")
yax = list(title = "Assault")
zax = list(title = "Rape")
Murders = USArrests$Murder
Assaults = USArrests$Assault
Rapes = USArrests$Rape
figure = plotly::plot_ly(x=Murders,y=Assaults,z=Rapes,
width = 800, height = 500,
type = "scatter3d", mode="markers", name="States",
text = paste0("State: ", row.names(USArrests),
"<br>Murders: ", Murders,
"<br>Assaults: ", Assaults, "<br>Rapes: ", Rapes),
hoverinfo = "text") %>%
plotly::layout(scene = list(xaxis=xax, yaxis = yax, zaxis = zax)) %>%
plotly::layout(title = "US States and their Crime Rates")
figure
Linear Regression: \[ y = \beta_0 + \beta_1x + \epsilon \] Finding the Least Squares, Best Fit Line: \[ \beta_1 = \frac{\sum(x_i - \overline{x})(y_i - \overline{y})}{\sum(x_i - \overline{x})^2} \] \[ \beta_0 = \frac{\sum y_i - \beta_1 \sum x_i}{n} = \overline{y} - \beta_1 \overline{x} \]
\[ 1 = cos^2(x) + sin^2(x) \] \[ \int{e^{f(x)}f'(x)dx} = e^{f(x)} + c \] \[ \int{(ax + b)^ndx} = \frac{1}{a}\frac{(ax+b)^{n+1}}{n+1}+c, n\ne-1 \]
\[ \frac{df}{dt}=\lim_{h\to0}{\frac{f(t+h) - f(t)}{h}} \]
\[ a = \frac{dv}{dt},\int_{v_0}^{v}dv = \int_{0}^{\Delta t}a\;dt \]
Slide 2 involved a Plotly based 3-D scatter plot. This is an interactive plot that shows each state and where they land in the 3d space regarding their 3 reported crime stats.
Slide 3 is the code required to produce Slide 2’s plot.
Slide 4 is a ggplot2 based scatter plot that plots the relation of each crime as different colors. Then is calculates regression lines for each crime type to determine if there’s an correlation of that crime type to urban population proportion.
Slide 5 shows the equations for linear regression and how one would calculate a best fit line.
Slide 6 is a ggplot2 based stacked bar plot showing the percentages that each crime type consist of out of the 3 reported crime types, and shows one for each state.
Slide 7 is a slide showing cool, and semi complex equations crafted using latex.