Wednesday, October 25, 2017

Assignment 3: Statistical Analysis

Introduction: Housing foreclosures are an issue in certain parts of the country, and it might affect some census tracts in Dane County, Wisconsin. In this report, the number of housing foreclosures from 2011 and 2012 will be investigated and compared in order to determine if Dane County officials need to be worried about an increase in foreclosures. Some of the questions this research hopes to answer are "how have the number of foreclosures changed from 2011 to 2012"; "if the number of foreclosures are increasing year-to-year, what is the probability that they continue to increase or decrease in subsequent years;" and "what number of foreclosures for all of Dane County will be exceeded 80% of the time, and 10% of the time?"

Methodology: In order to determine the change in foreclosures from 2011 to 2012, US Census Tract data was utilized. The US Census data was important because it provided the number of foreclosures for the years need. In relation to the data, a field was added to the data in ArcMap depicting the change in the number of foreclosures from year to year. This added field helps determine whether or not the number of foreclosures increased, decreased, or stayed the same.

Also, mean, median, standard deviation, and Z-score were calculated in order to better understand certain statistics associated with the number of foreclosures. Calculating the mean is important because it displays the average change in foreclosures between the years 2011-2012, and the average number of foreclosures for both years. However, calculating the median is also important because it ignores potential outliers, so it could represent a more balanced data representation. The standard deviation is important because it shows the variability of the changes from 2011-2012 for each census tract in relation to the mean, and for each year.

Z-Scores were calculated for 3 separate census tracts--tract number 25, 108, and 120.01 for 2011 and 2012 (so 6 z-scores in total) for sampling purposes. To provide a definition: a z-score is based on the observation's relation to the mean. So for example: if the mean is 12, and the observation is also 12, the z-score will be 0 because they are the same number (if the obsersation is greater than 12, the z-score will be greater than 0. If the observation is less than 12, the z-score will be less than 0. Usually z-scores fall in the ± 3 range). Z-scores are important for analyzing the data because it shows probability of future foreclosures in a given census tract (which can be obtained using the chart in Figure 1.
Figure 1: Z-Score Chart
In order to calculate Z-Score, one would subtract the observation by the mean, then divide by the standard deviation.

Results: To provide some statistics associated with foreclosures:

Foreclosures in 2011:
Mean = 11.39 foreclosures per tract
Median = 11.00 foreclosures per tract
Standard Deviation = 8.78

Foreclosures in 2012:
Mean = 12.30 foreclosures per tract
Median = 10.00 per tract
Standard Deviation = 9.91

In comparing the number of foreclosures between two years, the average number of foreclosures rose by .91 properties, however the median dropped from 11 foreclosures per tract to 10. The increase in foreclosures seems to mean certain tracts' foreclosures increased somewhat dramatically from one year to the next, which increased the mean. The standard deviation also increased from 2011 to 2012, which means there is more variability in the number of foreclosures in relation to the mean (i.e. if the standard deviation were like 1 for example, the number of foreclosures would be clustered around the mean, verses if it's higher then the number of foreclosures aren't as clustered around the mean).

In mapping the change of foreclosures between 2011-2012, Figure 2 represents either the increase or decrease in foreclosures between years. 
Figure 2: Map of changes in number of foreclosures from 2011-2012

As depicted by Figure 2, the light blue/dark blue colors represent a decrease in foreclosures between 2011-2012; the yellow represents no change in the number of foreclosures, and the orange/red represent an increase in the number of foreclosures. It seems that  increase in foreclosures are situated in the far-eastern and northwestern part of the county, whereas decreases seemed to happen most in the center of the county.

Also, another map depicting the standard deviations for foreclosures in both years was created to see the rate of foreclosure deviating from the mean, located in Figure 3. 
Figure 3: Comparative Map of Standard Deviation of Foreclosures from 2011-2012
 To reiterate, the mean number of foreclosures for 2011 was 11.39 per tract, while for 2012 the mean number was 12.30. It seems that in 2011, the northern tracts exhibited a high positive standard deviation, which means the number of foreclosures is higher than the mean; whereas, in 2012 the standard deviations are still positive, however not as large of a standard deviation as the 2011 tracts. It doesn't seem the rate of foreclosures deviated too much from year to year, especially in the central part of the county, which means the rate of foreclosures is staying consistent to the averages. A couple of the northern tracts decreased their standard deviation, which means the rate of foreclosures most likely went down for the tract.

Using the mean and standard deviation for 2012, in calculating probability using Z-scores, the Z-score for "exceeding 80%" was -.84. Assuming the patterns for 2012 hold the next year in Dane County, there is an 80% chance that there will be more than 3.98 foreclosures per census tract (which there can't be a fraction of a house foreclosed, so approximately 4 foreclosures per census tract). For "exceeding 10%", the Z-score was 1.28, and using the Z-score, there is a 10% chance foreclosures will exceed 24.98 (or approximately 25 foreclosures). If comparing the probability to tracts in the below map in Figure 3, there will be at least 4 foreclosures in most census tracts (minus a few red ones); however, there will probably be at least 25 foreclosures in the darkest and second darkest blue areas (i.e. Tract 120.01), because they already have a high number of foreclosures.

For sampling purposes, tracts 108, 25, and 120.01 were utilized to show how z-score can be used to calculate probability (as depicted in Figure 3. If it's too hard to see, 108 is the southwest one, 25 is the most north, and 120.01 is the most east). The 2011 and 2012 Z-scores for tracts 108, 25, and 120.01 are:

108: 2011 Z-Score is 2.01, 2012 Z-Score is 1.48
25: 2011 Z-Score is -.61, 2012 Z-Score is -.94
120.01: 2011 Z-Score is 1.78, 2012 Z-Score is 3.0

For tract 108, the Z-score was 2.01 in 2011 and 1.48 in 2012. Using the chart in Figure 1, that means out of all of the tracts in Dane county, that means in 2011 2.22% of the time foreclosures will exceed its original observation (which was 29 foreclosures), while in 2012 6.94% of the time the foreclosures will exceed its original observation (which was 27 foreclosures).

In tract 25, the Z-score was -.61, and in 2012 -.94. That means in 2011, 72.91% of all foreclosures will be greater than the original observation (which was 6), and in 2012 82.64% of all foreclosures will be greater than the original observation (which was 3).

In tract 120.01, the Z-score for 2011 was 1.78, while in 2012 it was 3.0. That means in 2011, 3.75% of the observations will be greater than the original observation (which was 27), while in 2012 .14% of the observations will be greater than the original observation (which was 42).

Conclusion: The purpose of this assignment was to determine how the number of foreclosures have changed from year to year per census tract, and the probability of increasing/decreasing of foreclosures in subsequent years. In comparing the number of foreclosures from 2011 to 2012, the mean rose by .91 foreclosures, however the median shrank by 1 foreclosure. The tracts stayed relatively consistent year-to-year in relation to the standard deviation, some decreased their standard deviation from year to year which means the number of foreclosures most likely went down. Most of the census tracts will have at least 3 foreclosures in their area; however, ones who have at least 25 are in the 90th percentile, which means certain tracts on the eastern part of the county (i.e. 120.01) are having houses foreclosed at a high rate.

Tuesday, October 10, 2017

Assignment 2: Standard Deviation and Mean Center

Part 1

Introduction: The purpose part 1 was to become familiar with the real world applications of statistics and how to calculate them. In this assignment, sample test scores from two different high schools were utilized. Multiple different kinds of statistics were calculated in order to compare the test scores from the two high schools. 

Definitions: Before delving into calculations, it is important to define each of the different kinds of statistics calculated. Range is taking the lowest value, and subtracting it from the highest value to display the differences in value. So for example, if the highest test score was a 192 out of 200, and the lowest was a 111, the range would be 192-111, which is 81. Mean is the average of all of the values, which is found by adding up all of the observations, then dividing them by the number of observations. So for test scores, if there were 5 test scores (lets say 153, 135, 120, 188, and 180), one would add up all of those values to equal 776, then divide it by 5 to equal a mean of 155.2. 

Median is finding the exact middle of the values if they were all ordered numerically. So if there are 7 test scores (lets say 3, 6, 7, 9, 10, 11, 12--they did really bad on this test), the median would be 9 because 9 is the exact middle (if there are an even number of observations, the exact middle is then the average of the two middle observations). Mode is finding the value seen the most in the data. So for example, if there are 10 test scores (lets say 128, 123, 153, 153, 152, 122, 153, 155, 153, 153), 153 would be the mode because there are the most test scores in that data that equal 153. 

Kurtosis is essentially how peaked or flat the data is when it is graphed. So for example, if the data is really peaked (i.e the line looks like Figure 1), the test scores are closer to the average. Whereas if the data is flat (i.e. the line looks like Figure 2), the test scores are farther away from the average. If a Kurtosis equals a value greater than 1, it is considered peaked, while if it is less than -1, it is considered flat.

Figure 1: A peaked graph (taken from http://personal.cityu.edu.hk/~meachan/Online%20Anthropometry/Chapter5/Ch5-3.htm) 

Figure 2: A flat graph (taken from http://personal.cityu.edu.hk/~meachan/Online%20Anthropometry/Chapter5/Ch5-3.htm)
Skewness refers to how much the data leans to the left or the right when referring to a normal distribution. So if a normal distribution looks like Figure 1, a skewed distribution might look like Figure 3. Skewed distributions can either be positive (leaning to the left) or negative (leaning to the right). With regards to calculations, 0 means there is no skewness, anything below 0 is a negative skewness, and anything above 0 is a positive skewness. 
Figure 3: An example on skewness (taken from https://en.wikipedia.org/wiki/Skewness)
Standard Deviation refers to how much the data deviates from the average. So for example with test scores: if the average is 150, and there is a standard deviation of 2, a majority of the students' test scores should fall between 150 + or - 2, because the standard deviation determines how the data will cluster around the average (if one were to add another two, i.e. 150 + or - 4, then the overwhelming majority will have their test scores fall between that spectrum). For standard deviation, there are two types of equations: normal standard deviation and sample standard deviation. Normal standard deviation takes into account all of the observations (so if there were 500 students taking a test, normal standard deviation would take into account all 500 students), while sample standard deviation only takes a select number of observations (so if someone wanted to calculate the standard deviation for 200 out of the 500 students, they would use a sample standard deviation equation). The two equations for each are located in Figure 4 and Figure 5.

Standard Deviation:
Figure 4: Standard Deviation (taken from http://libweb.surrey.ac.uk/library/skills/Number%20Skills%20Leicester/images/pic013.gif)
Sample Standard Deviation:
Figure 5: Sample Standard Deviation (taken from http://libweb.surrey.ac.uk/library/skills/Number%20Skills%20Leicester/page_19.htm)
The only difference between the two is in its division. In normal standard deviation, the top equation is divided by the total number of observations, while in sample the top equation is divided by the number of observations in the sample minus one.

Calculations: For this assignment, all of the statistics defined above were calculated with regards to the two high schools' test scores in Figure 6. The statistics on the left refer to North High School, while the ones on the right refer to Memorial.
Figure 7: The two high schools' test scores
 For North High School: Range = 83. Mean =160.92. Median = 164.5. Mode: 170. Kurtosis = -.056. Skewness = 2.42. Standard Deviation = 23.64.

For Memorial High School: Range = 91. Mean = 158.54. Median = 159.5. Mode = 120.
Kurtosis =1.83. Skewness = -.18. Standard Deviation = 27.16.

For Standard Deviation, the deviation calculated was a sample standard deviation because the whole student bodys' test scores were not utilized, and for the assignment standard deviation was calculated out by hand in Figure 8 to become more familiar with its calculation process.
Figure 8: Sample Standard Deviation calculated out by hand


Discussion: In comparing the two schools, there was a previous perception that the students at North fare worse off in tests than at Memorial. In looking at the statistics, that perception seems to be false. North students' average test score was 160.92, compared to Memorial's 158.54. Now, given there may be couple of outliers throwing off the data; however, the median test score for North was 164.5, while at Memorial the median test score was 159.5. The fact that both the North's median and mean were larger than Memorial's contradicts the negative perception that North has lower test scores. There were other statistics calculated for both the schools, however mean and median best illustrate and debunk the negative perception of North because they show the average test score each student earned with the mean, however they also ignore potential outliers with the median. The fact North has a higher mean and median contradicts the theory of "Memorial has better test scores," because it shows that their students earn higher average test scores, but also how outliers didn't affect the data too much with the higher median.


Part 2

Introduction: The purpose of part 2 is to understand the definitions of mean center and weighted mean center, and apply those learned definitions to a map. 

Definitions: Before delving into the mapping the mean center and weighted mean center, it is important to define the two terms. Mean Center is the geographical center of a given area. So for example, if someone wanted to calculate the mean center for Wisconsin, they would take the mean center of all of the counties in Wisconsin using X,Y coordinates, then take the average of the counties to develop the mean center. Weighted Mean Center however, takes into account the mean center, but also adds another variable to it. So for example, if someone wanted to calculate a weighted mean center for Wisconsin by population, they would determine the population for each county, then weigh them based on those levels (counties with higher population weigh greater than populations with lower ones). The purpose of a weighted mean center is to take into account where the geographical center is, but also where the weight of the variable is pulling the data (so with regards to population, if the mean center is located in the middle of the state, the population weight might force the mean center into a different direction, depending on how the population is distributed across the state).

Maps: For this part of the assignment, a map was created in Figure 1 to show the mean center of Wisconsin, and the weighted mean centers by population for the years 2000 and 2015.

Figure 1: Map of Mean Center and Weighted Mean Centers by Population for Wisconsin
Discussion: For this map, the mean center and the weighted mean centers by population in 2000 and 2015 are displayed. The mean center shows the geographical center of Wisconsin, taking into account the average centers for all 72 counties, then averaging the X and Y coordinates of each county in order to place it on the eastern part of Wood County. With regards to the weighted mean centers by population in the years 2000 and 2015, the populations seem to be located in the same general area. In 2000, the population weight drew the point down closer to the southeastern part of the state, and with the 2015 weighted mean center the population moved slightly southwest from the 2000 weighted mean center; however, the overall weight of the population seems to be located in the same general area.


Assignment 6: Linear Regression

Part 1 Introduction : The goal of this assignment is to understand how to use regression to determine correlations between two variables....