Understanding the persistence of violent crime in cities can help determine which cities are being successful in reducing it and which cities are not. What is the relationship between the violent crime rate in 1990 and in 2000?
Note that we want to know more than just if there is a significant relationship. We want to:
Specify how much one influences the other.
Estimate violent crime rates in 2000, given the value in 1990.
Predict violent crime rates in 2000, given the value in 1990.
Example #1: Violent Crime Rate in 1990 vs. 2000
What is the relationship between these two variables?
The Theory
To summarize the relationship, we use a “line of best fit”:
\[
\hat{y} = \beta_0 + \beta_1 x
\]
However, this raises the following question: What do we mean by the “best” fit?
The Theory
This is the most important question we can answer. Different answers lead to different fitting methods.
MATH/STAT 225 covers a few of the different methods. (There’s always slots open in the winter term! Dr. Forsberg would love to have you!) It also covers the easiest method in great detail.
In this course, we will only look at the easiest method: ordinary least squares (OLS).
It is based on minimizing the sum of the squared residual values.
The Theory: The Line
The Theory: The Residuals
The Theory
Thus, our estimators of the \(y\)-intercept and slope (effect) are:
With this distribution, we are able to formulate confidence intervals and \(p\)-values for hypotheses about the slope (the effect of \(x\) on \(y\)).
The Theory: Slope
The proof of this is rather elementary and follows from the assumptions we make on the residuals. The three-line proof is provided in STAT 225. Also in that course is the proof of the confidence intervals and the \(p\)-values based on this distribution. (These are also three-line proofs.)
Note: Here, \(\sigma_e^2\) is the population variance of the residuals.
The Theory: ANOVA
Sometimes, we want to draw conclusions about the model, as a whole.
To do this, we rely on ANOVA (does the model give information about the dependent variable?). As such, we need to calculate the following variations:
Here, \(r\) is the correlation we learned about in the past.
The Theory: R
Help} Of course, for any real data set, it is unreasonable to do calculations by hand. The calculations can be done in R, of course:
The first step is to fit the model.
The second step is to summarize the results.
Returning to Example #1
This is the code to start to answer the questions raised at the start of this section:
# Load and attach the datadt =read.csv("crime.csv")attach(dt)### Create the modelmodOLS =lm(vcrime00 ~ vcrime90)### Print the results summary.aov(modOLS)
Df Sum Sq Mean Sq F value Pr(>F)
vcrime90 1 2556238 2556238 349.3 <2e-16 ***
Residuals 49 358600 7318
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Example #1: Violent Crime Rate in 1990 vs. 2000
The Interpretation:
Because the \(p\)-value is less than our usual \(\alpha = 0.05\), we reject the null hypothesis that the model does not offer significant understanding of the relationship between the violent crime rates in 1990 and 2000.
Example #1: Violent Crime Rate in 1990 vs. 2000
The ANOVA output tells us if the individual independent variables are statistically significant in describing the dependent variable. That is all the ANOVA output tells us.
If we want to determine things like the effect estimates, we use the “linear model” summary: summary.lm(modOLS)
Side Note: If you fit using the lm function, the summary function is equivalent to the summary.lm function. That is, summary(modOLS) gives the same results.
Example #1: Violent Crime Rate in 1990 vs. 2000
From this output, we at least know the following:
The effect of the 1990 violent crime rate on that of 2000 is \(0.58065\).
For every increase in the violent crime rate in 1990 of 1, the estimated violent crime rate in 2000 increases by \(0.58065\).
Those states with no violent crime in 1990 have an expected violent crime rate of 109.52716 in 2000.
The effect of the 1990 violent crime rate on the 2000 violent crime rate is not 0 (\(p\)-value \(\ll\) 0.0001).
Example #1: Violent Crime Rate in 1990 vs. 2000
Example #1: Violent Crime Rate in 1990 vs. 2000
The previous code provides the point estimates for the intercept and slope. However, as we already know, we also need a confidence interval to communicate the precision of our estimates.
We are 95% confident that the true effect of the 1990 violent crime rate on the 200 violent crime rate is between 0.518 and 0.643.
Example #1: Violent Crime Rate in 1990 vs. 2000
Since we can estimate a value of the dependent variable, we also need to calculate a confidence interval to indicate the precision of our estimate. Recall that the original problem had us estimate the 2000 violent crime rate for a state with a 1990 violent crime rate of 1500.
We are 95% confident that the expected violent crime rate in 2000 for a state with a violent crime rate of 1500 in 1990 is between 918 and 1043, with a point estimate of 981.
Example #1: Violent Crime Rate in 1990 vs. 2000
Finally, we can predict a value of the dependent variable for the next state with that value of the independent variable.
We are 95% confident that the actual violent crime rate in 2000 for a state with a violent crime rate of 1500 in 1990 is between 797 and 1164, with a point estimate of 981.
Example #1: Violent Crime Rate in 1990 vs. 2000
Example #2: Violent Crime against Education
What is the relationship between the violent crime rate in 2000 and the school enrollment in 1990?
The code for this analysis:
mod1 =lm(vcrime00 ~ enroll90)summary(mod1)
Call:
lm(formula = vcrime00 ~ enroll90)
Residuals:
Min 1Q Median 3Q Max
-406.58 -160.05 -55.30 98.19 1005.73
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -211.613 804.596 -0.263 0.794
enroll90 7.095 8.732 0.813 0.420
Residual standard error: 242.3 on 49 degrees of freedom
Multiple R-squared: 0.01329, Adjusted R-squared: -0.006843
F-statistic: 0.6602 on 1 and 49 DF, p-value: 0.4204
Example #2: Property Crime Rate in 1990 vs. 2000
Brief Conclusion:
Because the \(p\)-value of 0.4204 is greater than our usual \(\alpha = 0.05\), we cannot reject the null hypothesis. We did not detect a statistically significant relationship between the school enrollment in 1990 with the violent crime rate in 2000.
Example #3: Violent Crime against Wealth
What is the relationship between the violent crime rate in 2000 and average wealth of the state in 1990? Also, what is the predicted 2000 violent crime rate for a state with average weatlh $50,000?
Example #3: Violent Crime against Wealth
The code for this analysis:
mod2 =lm(vcrime00 ~ gspcap90)summary(mod2)
Call:
lm(formula = vcrime00 ~ gspcap90)
Residuals:
Min 1Q Median 3Q Max
-413.6 -123.9 -44.5 126.1 427.8
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 74.32013 88.97655 0.835 0.408
gspcap90 0.01598 0.00366 4.365 6.55e-05 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 207 on 49 degrees of freedom
Multiple R-squared: 0.28, Adjusted R-squared: 0.2653
F-statistic: 19.06 on 1 and 49 DF, p-value: 6.545e-05
Because the \(p\)-value is much less than our usual \(\alpha = 0.05\), we can reject the null hypothesis. We did detect a statistically significant relationship between the state’s average wealth in 1990 with the violent crime rate in 2000.
For every $1,000 increase in average wealth in the state, the 2000 violent crime rate increase by an average of between 8.6 and 23.3.
We predict that a state with a GSP per capita of $50,000 in 1990 will have a violent crime rate in 2000 between 409 and 1338, with a prediction of 873.
Example #4: Violent Crime against the Unemployment Rate
What is the relationship between the violent crime rate in 2000 and the unemployment rate in 1990? If there is a relationship, estimate the 2000 violent crime rate given the 1990 unemployment rate is 10%.
Example #4: Violent Crime against the Unemployment Rate
The code for this analysis:
mod3 =lm(vcrime00 ~ unemp1990)summary(mod3)
Call:
lm(formula = vcrime00 ~ unemp1990)
Residuals:
Min 1Q Median 3Q Max
-346.28 -146.21 -53.13 91.02 1035.79
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 293.51 168.04 1.747 0.087 .
unemp1990 27.06 30.09 0.899 0.373
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 241.9 on 49 degrees of freedom
Multiple R-squared: 0.01624, Adjusted R-squared: -0.003835
F-statistic: 0.809 on 1 and 49 DF, p-value: 0.3728
Example #3: Violent Crime against Wealth
Interpretation:
Because the \(p\)-value of 0.373 is greater than out usual \(\alpha = 0.05\), we cannot reject the null hypothesis. We did not detect a statistically significant relationship between the unemployment rate in 1990 with the violent crime rate in 2000.
Beyond Simple Linear Regression
The previous example had one numeric dependent variable and one numeric independent variable, hence Simple Linear Regression. However, research usually posits that multiple variables affect the variable of interest (response variable). For example:
state wealth depends on political, economic, and geographical factors.
propensity for terrorist activity depends on minority concentration, economic strengths, and past activity.
football power depends on the quality of the quarterback, the quality of the league, and the quality of the coach.
success probability in STAT 200 depends on professor, preparation, study habits, and events happening in your life.
Nothing we have discussed so far can handle this many independent variables.
Violent Crime vs. Urban Percent and Region
As a part of her research, a former Knox student hypothesized that there was a relationship between the violent crime rate and the percent of the population that is urban. She also hypothesized that this relationship differed across the four census regions.
Her actual research focused on policing policies across the United States and their effects on crime rate. This statistical work was just a small part of her effort. In fact, it was a very small part once she had the data.
From her literature review, she further hypothesized that there was a positive relationship between the violent crime rate and the urban percent, and that the relationship would be strongest in the Southern census region of the United States.
Why summary.aov? There is a categorical independent variable and we want to determine if the variable and/or its interaction is important.
Violent Crime vs. Urban Percent and Region
Note that the interaction between the two variables is significant (\(p= 0.0181 < 0.05 = \alpha\)). As such, both variables are important in the understanding of the violent crime rate in 2000 (in this model).
Furthermore, this result supports her second hypothesis, that the effect of urbanness on the violent crime rate varies from region to region.
Note: Only three of the four regions are listed here. This is because all of the effects (estimates) are measured with respect to this “base” category (Midwest). Thus, the region effect of the South is 281.398 less than for the Midwest. Also, the interaction effect for the South is 7.263 greater than for the Midwest.
Violent Crime vs. Urban Percent and Region
Because the table on the previous slide is difficult to understand (for everyone), here is a graphic of the results.
Violent Crime vs. Urban Percent and Region
Because it is important to illustrate your results with specific examples, let us estimate the 2000 violent crime rate for a specific southern state with an urban population of 90%:
From these results, a 95% confidence interval for the 2000 violent crime rate for a southern state with a 90% urban population is from 759 to 1087, with a point estimate of 923 violent crimes per 100,000 people.
Violent Crime vs. Urban Percent and Region
Again, because it is important to illustrate your results with specific examples, let us predict the 2000 violent crime rate for a southern state with an urban population of 90%:
From these results, a 95% prediction interval for the 2000 violent crime rate for a southern state with a 90% urban population is from 522 to 1324, with a point estimate of 923 violent crimes per 100,000 people.
Violent Crime vs. Property Crime and Region
What is the relationship between the 2000 violent crime rate and the 1990 property crime rate, when controlling for the four census regions?
Note that the interaction between the two variables is not statistically significant (\(p= 0.36556 > 0.05 = \alpha\)). As such, we need to modify our model by removing this interaction.
This decision arises from Occam’s Razor: All things being equal, the simpler model is the more useful. This translates as one should generally remove non-significant variables.
Both variables have a detectable effect. As such, this is our model.
Violent Crime vs. Property Crime and Region
summary.lm(mod2a)
Call:
lm(formula = vcrime00 ~ pcrime90 + census4)
Residuals:
Min 1Q Median 3Q Max
-364.84 -84.29 -15.69 62.73 500.83
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -143.37481 96.65541 -1.483 0.1448
pcrime90 0.12889 0.01999 6.448 6.15e-08 ***
census4Northeast -67.79721 70.31720 -0.964 0.3400
census4South 78.62681 62.83648 1.251 0.2172
census4West -155.24230 65.02444 -2.387 0.0211 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 159.4 on 46 degrees of freedom
Multiple R-squared: 0.599, Adjusted R-squared: 0.5641
F-statistic: 17.18 on 4 and 46 DF, p-value: 1.101e-08
Again: Note that only three of the four regions are listed here. This is because all of the effects (estimates) are measured with respect to this “base” category (Midwest). Thus, for instance, the region effect of the South is 78.63 greater than for the Midwest.
Violent Crime vs. Property Crime and Region
The following is a graphic of the relationships between the property and the violent crime rate across the four census regions.
Violent Crime vs. Property Crime and Education Level
What is the relationship between the 2000 violent crime rate and the 1990 property crime rate, when controlling for the level of education level of the state?
Note that this is a very different analysis than the previous ones. The two independent variables are both numeric. The analysis will be very similar, but the graphic will be quite different.
Violent Crime vs. Property Crime and Education Level
Note that the interaction between the two variables is not statistically significant (\(p= 0.6622 > 0.05 = \alpha\)). As such, we need to modify our model by removing this interaction.
Violent Crime vs. Property Crime and Education Level
Both variables have a detectable effect. As such, this is our model.
Violent Crime vs. Property Crime and Education Level
The important parts of the regression table are:
summary.lm(mod3a)
Call:
lm(formula = vcrime00 ~ pcrime90 + waea90)
Residuals:
Min 1Q Median 3Q Max
-305.65 -98.89 -17.21 75.19 575.08
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 555.94745 321.06193 1.732 0.0898 .
pcrime90 0.14060 0.02039 6.897 1.06e-08 ***
waea90 -12.54722 5.04317 -2.488 0.0164 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 171.4 on 48 degrees of freedom
Multiple R-squared: 0.5162, Adjusted R-squared: 0.4961
F-statistic: 25.61 on 2 and 48 DF, p-value: 2.7e-08
Violent Crime vs. Property Crime and Education Level
Interpretation: For every increase in the property crime rate of 1 in 100,000, the violent crime rate tends to increase by 0.14 points, all things being equal. Similarly, for ever increas in the weighted average educational achievement of one point, the violent crime rate drops by 12.55 points.
Violent Crime vs. Property Crime and Education Level
So, how do we illustrate the relationship between/among the two independent numeric variables and the dependent variable? It is quite difficult.
The key is to determine which variable you want to emphasize in your graphic. We shall designate this variable as the “\(x\)-variable”. Your \(x\)-variable will be assigned a range of values. All other variables need to be set to a specific value (or values).
Violent Crime vs. Property Crime and Education Level
Depending on how complicated your graphic, those specific values may be means, medians, or quartiles. This is where a conversation with others (and experience) is very useful. Remember that education is also a community activity. The best work is done with others.
Also, this is where acknowledging “good” is good enough is helpful. No graphic is perfect. They are (usually) good enough. They always have weaknesses, especially because different people look for different features in a graphic.
Violent Crime vs. Property Crime and Education Level
The following is a graphic of the relationships between the weighted average educational achievement and the violent crime rate for three exemplar property crime rates.
Beyond STAT 200
At this point in the course, we are technically able to model a Normally-distributed response variableand that’s all. In the future, you may wish to model dependent variables that are not Normal, that are:
just successes or failures (Bernoulli).
counts of successes over a specified number of trials (Binomial).
counts of successes over a specified time or region (Poisson).
These are covered in STAT 225. Here are some results you will be able to perform by the end of that course.
Dichotomous (Bernoulli) Response
The following is a graphic of the relationship between a homeowner’s age and the likelihood that the homeowner has purchased flood insurance.
Binomial Response
The following is a graphic of the relationship between a vote and the likelihood it was invalidated in the 2011 presidential election in Uganda.
Count (Rate) Response
The following is a graphic estimating the number of citizen’s initiatives in states based on their population and geographic region (for states that allow the initiative).