# dataset from url
violence <- read.csv("https://raw.githubusercontent.com/maharjansudhan/DATA620/master/USArrests.csv", sep = ",", header = TRUE)
violence
## State Murder Assault Rape UrbanPop TotalCrime
## 1 Alabama 13.2 236 21.2 58 270.4
## 2 Alaska 10.0 263 44.5 48 317.5
## 3 Arizona 8.1 294 31.0 80 333.1
## 4 Arkansas 8.8 190 19.5 50 218.3
## 5 California 9.0 276 40.6 91 325.6
## 6 Colorado 7.9 204 38.7 78 250.6
## 7 Connecticut 3.3 110 11.1 77 124.4
## 8 Delaware 5.9 238 15.8 72 259.7
## 9 Florida 15.4 335 31.9 80 382.3
## 10 Georgia 17.4 211 25.8 60 254.2
## 11 Hawaii 5.3 46 20.2 83 71.5
## 12 Idaho 2.6 120 14.2 54 136.8
## 13 Illinois 10.4 249 24.0 83 283.4
## 14 Indiana 7.2 113 21.0 65 141.2
## 15 Iowa 2.2 56 11.3 57 69.5
## 16 Kansas 6.0 115 18.0 66 139.0
## 17 Kentucky 9.7 109 16.3 52 135.0
## 18 Louisiana 15.4 249 22.2 66 286.6
## 19 Maine 2.1 83 7.8 51 92.9
## 20 Maryland 11.3 300 27.8 67 339.1
## 21 Massachusetts 4.4 149 16.3 85 169.7
## 22 Michigan 12.1 255 35.1 74 302.2
## 23 Minnesota 2.7 72 14.9 66 89.6
## 24 Mississippi 16.1 259 17.1 44 292.2
## 25 Missouri 9.0 178 28.2 70 215.2
## 26 Montana 6.0 109 16.4 53 131.4
## 27 Nebraska 4.3 102 16.5 62 122.8
## 28 Nevada 12.2 252 46.0 81 310.2
## 29 New Hampshire 2.1 57 9.5 56 68.6
## 30 New Jersey 7.4 159 18.8 89 185.2
## 31 New Mexico 11.4 285 32.1 70 328.5
## 32 New York 11.1 254 26.1 86 291.2
## 33 North Carolina 13.0 337 16.1 45 366.1
## 34 North Dakota 0.8 45 7.3 44 53.1
## 35 Ohio 7.3 120 21.4 75 148.7
## 36 Oklahoma 6.6 151 20.0 68 177.6
## 37 Oregon 4.9 159 29.3 67 193.2
## 38 Pennsylvania 6.3 106 14.9 72 127.2
## 39 Rhode Island 3.4 174 8.3 87 185.7
## 40 South Carolina 14.4 279 22.5 48 315.9
## 41 South Dakota 3.8 86 12.8 45 102.6
## 42 Tennessee 13.2 188 26.9 59 228.1
## 43 Texas 12.7 201 25.5 80 239.2
## 44 Utah 3.2 120 22.9 80 146.1
## 45 Vermont 2.2 48 11.2 32 61.4
## 46 Virginia 8.5 156 20.7 63 185.2
## 47 Washington 4.0 145 26.2 73 175.2
## 48 West Virginia 5.7 81 9.3 39 96.0
## 49 Wisconsin 2.6 53 10.8 66 66.4
## 50 Wyoming 6.8 161 15.6 60 183.4
names(violence)
## [1] "State" "Murder" "Assault" "Rape" "UrbanPop"
## [6] "TotalCrime"
# lets' find out the highest murder, assault, rape
high_murder <- subset(violence, Murder == max(Murder))
print(high_murder)
## State Murder Assault Rape UrbanPop TotalCrime
## 10 Georgia 17.4 211 25.8 60 254.2
high_assault <- subset(violence, Assault == max(Assault))
print(high_assault)
## State Murder Assault Rape UrbanPop TotalCrime
## 33 North Carolina 13 337 16.1 45 366.1
high_rape <- subset(violence, Rape == max(Rape))
print(high_rape)
## State Murder Assault Rape UrbanPop TotalCrime
## 28 Nevada 12.2 252 46 81 310.2
It is confirmed that Georgia, North Carolina and Nevada has the somewhat highest crime rates.
# lets' find out the lowest murder, assault, rape
low_murder <- subset(violence, Murder == min(Murder))
print(low_murder)
## State Murder Assault Rape UrbanPop TotalCrime
## 34 North Dakota 0.8 45 7.3 44 53.1
low_assault <- subset(violence, Assault == min(Assault))
print(low_assault)
## State Murder Assault Rape UrbanPop TotalCrime
## 34 North Dakota 0.8 45 7.3 44 53.1
low_rape <- subset(violence, Rape == min(Rape))
print(low_rape)
## State Murder Assault Rape UrbanPop TotalCrime
## 34 North Dakota 0.8 45 7.3 44 53.1
It seems like North Dakota has the least crime rates in USA.
population <- lm(TotalCrime ~ UrbanPop, data = violence)
summary(population)
##
## Call:
## lm(formula = TotalCrime ~ UrbanPop, data = violence)
##
## Residuals:
## Min 1Q Median 3Q Max
## -159.32 -67.09 -18.31 76.49 202.83
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 83.280 60.046 1.387 0.1719
## UrbanPop 1.778 0.895 1.986 0.0528 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 90.69 on 48 degrees of freedom
## Multiple R-squared: 0.07593, Adjusted R-squared: 0.05668
## F-statistic: 3.944 on 1 and 48 DF, p-value: 0.05276
qqnorm(resid(population))
qqline(resid(population))
It seems like lower the population there is low chances of crime and higher the population more crimes happen. The data is also linear.