Sunday, December 17, 2017

Assinment 6

Regression Analysis

Definitions:

Regression Analysis: Used to find the relationship between two variables, and also to investigate the causation.
Coefficient of Determination (r2): shows how much X explains Y/ ranges from 0(no strength) to 1(very strong)
Regression Equation:
  • a= the constant: the point where the best fit line crosses the Y axis or when x=0
  • b= the slope of the line or the Regression Coefficient: shows how responsive the dependent variable is to change in the independent variable.
  • Y= dependent variable
  • X= independent variable





Ordinary Least Squares (OLS): Fighting a straight line through a set of points in such a way that the sum of the squared vertical distances from the observed points to the fitted line is minimized.
Dependent: What is explains by the independent variable always found on the Y axis.
Independent: What explains the dependent variable always found on the X axis. 

Part I:

Introduction: There was a claim by Town X's local news that as the number of kids that receive free lunches increases so does crime. This claim was based on data from a study the town conducted on crime rates and poverty per 100,000 people. This claim seems to put a far stretch for the data given. Running a regression equation would be a good way to either falsify or approve this claim by the local news. SPSS is a good medium to run the regression equation of if 30% of a new area of town gets free lunch what would the corresponding crime rate be. As well as to find out how confident the results are from this question.

Methodology: To complete this task you would run a regression analysis in SPSS. First realize that crime rate is the dependent variable while kids with free lunches is the independent variable. Then you would find your regression equation from the analysis finding the constant and the slope, and then plug in the 30% for the X value to find the Y value of the corresponding crime rate.


Results: The results show a R squared of .173 which means that there very little strength showing that the independent variable (free lunches) explains the dependent variable (crime rate). Also from the results we see that the constant is 21.819 and the slope is a positive 1.685.

Conclusions: We can conclude by these results that the claim by the news station was incorrect. The coefficient of determination is .173 on a 0 to 1 scale of strength meaning that it is weak. Other factors to take into account is that the significance level is .005 meaning that the two are correlated, but you can not tell causation from this. In terms of the new are with 30% free lunch the corresponding crime rate would be 72.5%, but I am not very confident in the results because of how weak the coefficient of determination value was. 

Part II:

Introduction: Being provided with 911 calls for Portland, OR , a company is curious as to what factors provide explanations about response times to these calls. With this information they are looking to build a new ER and would like to know how large to build it along with where the best location for it might be. The size of the ER is a question that is unanswerable with the data given, but the question that will be answered through this section is the best location to build this new ER.
The other data given was:

  • Number of 911 calls per census tract
  • Jobs
  • Renters
  • Low education: Number of people with no High School Degree
  • Alcohol sales
  • Unemployed
  • Foreign Born population
  • Medium Income
  • Number of College graduates
Choosing three of many data given analyze those three using a Regression Analysis to figure out the relationships.


Methods: I ran each independent variable through SPSS using the Regression Analysis where the dependent variable is the Calls data. Shown in Figure 1 is what is run in SPSS for each three with the independent variable being the one changed out.
Figure 1: Linear Regression Analysis Sample
After going through all the Regression Analyzes then I found the variable with the highest R-squared value. Then I made a Choropleth Map of just the 911 calls along with a Residual Map of the the highest R-squared value which was for the variable of Renters. To make the Residual Map you go into the Spatial Statistics Tools and make it in Ordinary Least Squares.

Results:
Figure 2: Low Education Regression Analysis

Figure 3: Renters Regression Analysis
-This was the Independent Variable with the highest Coefficient of Determination which was .616 as the r squared. The hypothesis for this would be:
Null Hypothesis= There is no linear relationship between 911 Calls and Renters
Alternative Hypothesis= There is a linear relationship between 911 Calls and Renters
-This would reject the null hypothesis because of the significance being .000  meaning there is a linear relationship between the two. This is also true for the other two independent variables I chose, so they all had linear relationships with 911 Calls, but Renters just had a higher Coefficient of Determination. 

Figure 4: Unemployment Regression Analysis 
Figure 5: Choropleth Map of 911 Calls
The Blue and Green areas are that of higher 911 calls. So they are above the trend-line.
Figure 6: Standard Deviation for Choropleth Map
Figure 7: Standard Residuals Map of Renters

The reddish to orange color is areas that above the trend-line meaning they are higher than the average for Renters. This correlates with Figure 5 where the blue colors are on that map of higher average 911 calls these two have a higher relationship in that area.

Conclusions: For the first question of what factors provide response times to 911 calls. My answer to that in terms of my independent variable would be that the number of response calls is highly correlated with the Renters in the area. The places of highest 911 calls is where the higher averages are for renters seen in Figure 7. For the second question about where the best location is for the ER I chose the spot represented by the circle on Figure 7. It was in between the two areas of the highest points from away from the trend-line like I discussed in the results section about the Standard Residuals Map along with it being centered among most of the reddish/peach areas. The ER should be fairly big in size compared to if it was located else where in Portland, but like stated in the Introduction there is no way to actually answer the size question. 

Monday, December 4, 2017

Assignment 5

Assignment 5
Correlation and Spatial Auto-correlation 

Part I: Correlation 

Definitions:
Correlation= Measures the association between pairs of variables, but does not imply causation
-There is two factors that go into correlation, one is strength and the other is direction
Strength= The strength between two variables ranges from a positive to a negative one where positive one is the strongest.
Direction= The relationship can either be positive, null (no difference), or negative. 
Co-variation= the measure of how two variables change together
Hypothesis Testing with Correlation= To determine if an association exists between two variables 
Spatial Auto-correlation= Correlation of a variable with its self through space. So if neighboring areas are more a like it is a positive and negative if unalike. 
Moran's I: A chart of 4 quadrants of comparison ranging between positive and negative 1 showing the strength of the auto correlation. High, High = (+,+), High, Low = (+,-), Low, High = (-,+), Low, Low = (-,-). 
LISA map: The purpose of these maps is show a spatial component of the spatial auto-correlation. 4 categories of color that correlate with the strength of the relationships described in Moran's I. Red related to high and blue related to low. 

1. Using the data in Image 1, create a scatter-plot and place a trend line on that scatter-plot in Excel. The scatter-plot created is seen in Image 2. To find the Pearson correlation use SPSS which is shown in Image 3. 
-Null Hypothesis= There is no significant difference between distance and sound level
-Alternative Hypothesis= This is a significant difference between distance and sound level
Image 1: Scatter-plot Data

Image 2: Scatter-plot

Image 3: Correlation
Results Summary: From Image 2 and Image 3 you will find that there is a significant (because of the two asterisks) strong relationship because of the Pearson Correlation being -.896 along with the direction being negative because of the -.896 as well. The Sig 2-tailed test is .000, so that means that you reject the null hypothesis which is there is no significant difference between distance and sound level. 

2. Census Tracts and Population in Detroit, Mi

Results:
From this correlation matrix of Detroit there are a lot of things to infer. There are only two categorizes for whites that were not significant and that was the manufacturing and Finance categories. Looking at there sig 2-tailed test they both failed to reject the null  hypothesis which make sense then. For the black population all the categories have significant relationships besides that of the number of Finance Employees. For the Asian population all the relationships are significant besides with the Hispanic population category. With the Hispanic population there were five categorizes that were not significant with it. The categories were Asians, number of Bachelor's Degrees, number of manufacturing employees, number of retail employees, and number of Finance employees. There are certain correlations that stand out in terms of strength and direction. There is the strongest positive relationship between Asians and number of Retail employees, and Blacks had the strongest negative relationship. So, the probability you will see Asians being employed in retail is far higher than Blacks in Detroit.

Part II: Spatial Auto-correlation

Introduction: Given data of the percent Democratic votes and voter turnout from the Texas Election Commission for the years 1980 and 2012 Presidential Elections has there been any clustering patterns of these two values over the last 32 years? Using SPSS and GeoDa to answer this question and report the findings for the Texas Election Commission. Also, by using the online Census Data compare this to Hispanic population of Texas counties in 2010. This will all help to determine if there is a spatial auto-correlations for each of the elections with voting and voting turnout.

Method: To start off with this task for the TEC first you download the shape-file of Texas and the data of Hispanic Population 2010 from the online U.S. Census. For the Hispanic Data only the population percent is necessary so deleting row A2 and the rest of the columns is an important step to take once you have the excel spreadsheet of the data opened. In ArcMaps, open the shape-file of Texas downloaded from the Census, and join the Hispanic data along with the Texas voting patterns data provided by TEC to that Texas shape-file. While doing this make sure to use Geo_ID for joining. After joining export that shape-file with the data as a new shape-file so it is ready to use in GeoDa. Open GeoDa and click on "New Project From" and open this new Texas shape-file. You then have to create something refereed to as a "Spatial Weight".To do this go to tools, then create weight manager and ADD ID VARIABLE. Then under contiguity weight select Rook contiguity, and then hit create. After this is done begin to create Moran's I charts along with LISA cluster maps(make sure they are Uni-variate for both Moran's and LISA) for percent votes in 1980 and 2012 along with voter turnout in 1980 and 2012. Do this as well for Hispanic Voters, along with make a weights matrix's for this as well.

Results: Below are each of the Moran's I charts and each of the LISA cluster maps for voting and voter turnouts. There is also provided a Moran's I chart and LISA cluster map for Hispanic population. The last thing included is a weights matrix's for all of the categories.
Image 4: LISA map of Percent Democratic vote for 1980


Image 5: Moran's I chart of percent Democratic Vote for 1980
Image 6: LISA map percent Democratic Vote for 2012
Image 7: Moran's I chart of percent Democratic Vote for 2012

Image 8: LISA map of Voter Turnout for 1980

Image 9: Moran's map of Voter Turnout for 1980

Image 10: LISA map of Voter Turnout in 2012

Image 11: Moran's I chart of Voter Turnout in 2012
Image 12: LISA map of Percent Hispanic Population

Image 13: Moran's I chart of percent Hispanic Population



Conclusion:

There was a lower democratic vote increase over the past 32 years in northern and mid Texas, and an increase in Democratic vote in Southern Texas along the boarder. On the Moran's I charts in 2012 percent Democratic vote was much more clustered negatively than in 1980 which was much more spread out. There was still a higher number of Low-Low counties in 2012 as there were in 1980 just an increase in Low-Low in 2012. Voter turnout isn't clustered very tightly, but in 2012 there seems to be more of a cluster in High-High than there was in 1980. Comparing Democratic Vote to Voter turnout, in the areas of Democratic Voting High-High there is a voter turnout of Low-Low. This connects to the chart and map of Hispanic population because that is the area of High-High. Not much changed in voter turnout from 1980 to 2012 besides an increase in High-High in the northern tip counties along with a transition the most east part of the state from Low-Low to white. This means more people showed up to the poles in northern Texas along with in West Texas. There was a change from High-Low to Low-Low voter turnout in southern Texas from 1980 to 2012, so less people showed up to vote correlating to less Hispanics showing up to vote. Spatially there was not much change in voter turnout over 32 years, but for percent Democratic vote the area as to which were high and low didn't change but became more dense and gained surrounding counties.