Skip to main content

Appendix B Regression Analysis: A Refresher

In this appendix we present a very brief and high-level overview of regression analysis, in order to give some reference to when we introduce spatial regression in Chapter 11. We will follow a practical approach, working through one dataset to illustrate regression basics using R. For those who wish to have a more thorough grounding please refer to the further reading section at the end of this appendix.
Here we will return to the “ncovr” data set produced as part of the National Consortium on Violence Research (NCOVR) agenda (we use this also in chapter 11; for more information on this data see [281]). The data set includes variables related to homicides in the US, as well as information on a number of sociodemographic variables that are often thought of as associated with the geographical distribution of homicides. This data set is available as part of the geodaData package.
library(geodaData)
data("ncovr")
The dataset contains information about the counties in the United States and if you view it you will see it has information about several decades: the 60s, 70s, 80s, and 90s. The number at the end of the variable names denotes the relevant decade, and you will see that for each decade we have the same variables.
The purpose of regression analysis as we approach it here is to choose a model to represent the relationship between homicide and various predictors. You can think of a model as a map. A map aims to represent a given reality, but as you may have already discovered there are many ways of presenting the same information through a map. As an analyst you decide what the most appropriate representation for your needs is. Each representation you choose will involve an element of distortion. Maps (and models) are not exact representations of the real world, they are simply good approximations that may serve well a particular functional need. You may think about the map of the London Underground. It doesn’t show you geographically where the Underground lines of London are; yet, if you want to use the Metro system, this map will be extremely helpful to you. It serves a need in a good way. The same happens with models. They may not be terribly good reflections of the world, but may give us approximations that allow us to develop useful insights.
Choosing a good model is like choosing a good way for displaying quantitative information in a map. Decisions, decisions, decisions. There are many parameters and options one can choose from. This can be overwhelming, particularly as you are learning how to model and map phenomena. How to make good decisions is something that you learn in earnest by practice, practice, practice. Nobody expects you to get the maps you are doing as you are learning, and the models you are developing as you are learning spot on. So please do not stress out about this. All we can do here is to learn some basic principles and start getting some practice, which you will be able to further develop in a professional context or in further training.
The first step in any analysis is to develop some familiarity with the data you are going to be working with. We have been here before. Read the codebook. Run summary statistics for your quantitative variables, frequency distributions for your categorical variables, and visualise your variables. This will help you to detect any anomalies and give you a sense for what you have. If, for example, you run a histogram for the homicide rate for 1990 (HR90), you will get a sense of the distribution form, which of course is skewed.
library(ggplot2)
qplot(x = HR90, data = ncovr)
Figure B.0.1. Histogram of the HR90 variable
Once one has gone through the process of exploring the data in this way (or maybe using the skimr package; see Appendix: A Quick Intro to R and RStudio) for all the variables you want to work with, you can start exploring bivariate associations with your dependent, response, or outcome variable. So, as an illustration, you could explore the association with resource deprivation (RD90), a measure of the level of concentrated disadvantage or social exclusion in an area, via a scatterplot:
ggplot(ncovr, aes(x = RD90, y = HR90)) +
  geom_point(alpha=.2)
Figure B.0.2. Scatterplot showing relationship between resource deprivation (RD90) and homicide rate (HR90) in the 90s
What do you think when looking at this scatterplot? Is there a relationship between the variables? Does it look as if individuals that have a high score on the x axis also have a high score on the y axis? Or vice versa?