Question 5.1 Using crime data from the file uscrime.txt (http://www.statsci.org/data/general/uscrime.txt, description at http://www.statsci.org/data/general/uscrime.html), test to see whether there are any outliers in the last column (number of crimes per 100,000 people). Use the grubbs.test function in the outliers package in R.
#read in data
UScrimeData <- read.delim("G:/My Drive/School/GT/ISYE-6501/hw3/uscrime.txt", header=T)
UScrimeData
## M So Ed Po1 Po2 LF M.F Pop NW U1 U2 Wealth Ineq Prob
## 1 15.1 1 9.1 5.8 5.6 0.510 95.0 33 30.1 0.108 4.1 3940 26.1 0.084602
## 2 14.3 0 11.3 10.3 9.5 0.583 101.2 13 10.2 0.096 3.6 5570 19.4 0.029599
## 3 14.2 1 8.9 4.5 4.4 0.533 96.9 18 21.9 0.094 3.3 3180 25.0 0.083401
## 4 13.6 0 12.1 14.9 14.1 0.577 99.4 157 8.0 0.102 3.9 6730 16.7 0.015801
## 5 14.1 0 12.1 10.9 10.1 0.591 98.5 18 3.0 0.091 2.0 5780 17.4 0.041399
## 6 12.1 0 11.0 11.8 11.5 0.547 96.4 25 4.4 0.084 2.9 6890 12.6 0.034201
## 7 12.7 1 11.1 8.2 7.9 0.519 98.2 4 13.9 0.097 3.8 6200 16.8 0.042100
## 8 13.1 1 10.9 11.5 10.9 0.542 96.9 50 17.9 0.079 3.5 4720 20.6 0.040099
## 9 15.7 1 9.0 6.5 6.2 0.553 95.5 39 28.6 0.081 2.8 4210 23.9 0.071697
## 10 14.0 0 11.8 7.1 6.8 0.632 102.9 7 1.5 0.100 2.4 5260 17.4 0.044498
## 11 12.4 0 10.5 12.1 11.6 0.580 96.6 101 10.6 0.077 3.5 6570 17.0 0.016201
## 12 13.4 0 10.8 7.5 7.1 0.595 97.2 47 5.9 0.083 3.1 5800 17.2 0.031201
## 13 12.8 0 11.3 6.7 6.0 0.624 97.2 28 1.0 0.077 2.5 5070 20.6 0.045302
## 14 13.5 0 11.7 6.2 6.1 0.595 98.6 22 4.6 0.077 2.7 5290 19.0 0.053200
## 15 15.2 1 8.7 5.7 5.3 0.530 98.6 30 7.2 0.092 4.3 4050 26.4 0.069100
## 16 14.2 1 8.8 8.1 7.7 0.497 95.6 33 32.1 0.116 4.7 4270 24.7 0.052099
## 17 14.3 0 11.0 6.6 6.3 0.537 97.7 10 0.6 0.114 3.5 4870 16.6 0.076299
## 18 13.5 1 10.4 12.3 11.5 0.537 97.8 31 17.0 0.089 3.4 6310 16.5 0.119804
## 19 13.0 0 11.6 12.8 12.8 0.536 93.4 51 2.4 0.078 3.4 6270 13.5 0.019099
## 20 12.5 0 10.8 11.3 10.5 0.567 98.5 78 9.4 0.130 5.8 6260 16.6 0.034801
## 21 12.6 0 10.8 7.4 6.7 0.602 98.4 34 1.2 0.102 3.3 5570 19.5 0.022800
## 22 15.7 1 8.9 4.7 4.4 0.512 96.2 22 42.3 0.097 3.4 2880 27.6 0.089502
## 23 13.2 0 9.6 8.7 8.3 0.564 95.3 43 9.2 0.083 3.2 5130 22.7 0.030700
## 24 13.1 0 11.6 7.8 7.3 0.574 103.8 7 3.6 0.142 4.2 5400 17.6 0.041598
## 25 13.0 0 11.6 6.3 5.7 0.641 98.4 14 2.6 0.070 2.1 4860 19.6 0.069197
## 26 13.1 0 12.1 16.0 14.3 0.631 107.1 3 7.7 0.102 4.1 6740 15.2 0.041698
## 27 13.5 0 10.9 6.9 7.1 0.540 96.5 6 0.4 0.080 2.2 5640 13.9 0.036099
## 28 15.2 0 11.2 8.2 7.6 0.571 101.8 10 7.9 0.103 2.8 5370 21.5 0.038201
## 29 11.9 0 10.7 16.6 15.7 0.521 93.8 168 8.9 0.092 3.6 6370 15.4 0.023400
## 30 16.6 1 8.9 5.8 5.4 0.521 97.3 46 25.4 0.072 2.6 3960 23.7 0.075298
## 31 14.0 0 9.3 5.5 5.4 0.535 104.5 6 2.0 0.135 4.0 4530 20.0 0.041999
## 32 12.5 0 10.9 9.0 8.1 0.586 96.4 97 8.2 0.105 4.3 6170 16.3 0.042698
## 33 14.7 1 10.4 6.3 6.4 0.560 97.2 23 9.5 0.076 2.4 4620 23.3 0.049499
## 34 12.6 0 11.8 9.7 9.7 0.542 99.0 18 2.1 0.102 3.5 5890 16.6 0.040799
## 35 12.3 0 10.2 9.7 8.7 0.526 94.8 113 7.6 0.124 5.0 5720 15.8 0.020700
## 36 15.0 0 10.0 10.9 9.8 0.531 96.4 9 2.4 0.087 3.8 5590 15.3 0.006900
## 37 17.7 1 8.7 5.8 5.6 0.638 97.4 24 34.9 0.076 2.8 3820 25.4 0.045198
## 38 13.3 0 10.4 5.1 4.7 0.599 102.4 7 4.0 0.099 2.7 4250 22.5 0.053998
## 39 14.9 1 8.8 6.1 5.4 0.515 95.3 36 16.5 0.086 3.5 3950 25.1 0.047099
## 40 14.5 1 10.4 8.2 7.4 0.560 98.1 96 12.6 0.088 3.1 4880 22.8 0.038801
## 41 14.8 0 12.2 7.2 6.6 0.601 99.8 9 1.9 0.084 2.0 5900 14.4 0.025100
## 42 14.1 0 10.9 5.6 5.4 0.523 96.8 4 0.2 0.107 3.7 4890 17.0 0.088904
## 43 16.2 1 9.9 7.5 7.0 0.522 99.6 40 20.8 0.073 2.7 4960 22.4 0.054902
## 44 13.6 0 12.1 9.5 9.6 0.574 101.2 29 3.6 0.111 3.7 6220 16.2 0.028100
## 45 13.9 1 8.8 4.6 4.1 0.480 96.8 19 4.9 0.135 5.3 4570 24.9 0.056202
## 46 12.6 0 10.4 10.6 9.7 0.599 98.9 40 2.4 0.078 2.5 5930 17.1 0.046598
## 47 13.0 0 12.1 9.0 9.1 0.623 104.9 3 2.2 0.113 4.0 5880 16.0 0.052802
## Time Crime
## 1 26.2011 791
## 2 25.2999 1635
## 3 24.3006 578
## 4 29.9012 1969
## 5 21.2998 1234
## 6 20.9995 682
## 7 20.6993 963
## 8 24.5988 1555
## 9 29.4001 856
## 10 19.5994 705
## 11 41.6000 1674
## 12 34.2984 849
## 13 36.2993 511
## 14 21.5010 664
## 15 22.7008 798
## 16 26.0991 946
## 17 19.1002 539
## 18 18.1996 929
## 19 24.9008 750
## 20 26.4010 1225
## 21 37.5998 742
## 22 37.0994 439
## 23 25.1989 1216
## 24 17.6000 968
## 25 21.9003 523
## 26 22.1005 1993
## 27 28.4999 342
## 28 25.8006 1216
## 29 36.7009 1043
## 30 28.3011 696
## 31 21.7998 373
## 32 30.9014 754
## 33 25.5005 1072
## 34 21.6997 923
## 35 37.4011 653
## 36 44.0004 1272
## 37 31.6995 831
## 38 16.6999 566
## 39 27.3004 826
## 40 29.3004 1151
## 41 30.0001 880
## 42 12.1996 542
## 43 31.9989 823
## 44 30.0001 1030
## 45 32.5996 455
## 46 16.6999 508
## 47 16.0997 849
Selecting the last column ’Crime”
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
lastColumnUScrimeData <- select(UScrimeData,Crime)
lastColumnUScrimeData
## Crime
## 1 791
## 2 1635
## 3 578
## 4 1969
## 5 1234
## 6 682
## 7 963
## 8 1555
## 9 856
## 10 705
## 11 1674
## 12 849
## 13 511
## 14 664
## 15 798
## 16 946
## 17 539
## 18 929
## 19 750
## 20 1225
## 21 742
## 22 439
## 23 1216
## 24 968
## 25 523
## 26 1993
## 27 342
## 28 1216
## 29 1043
## 30 696
## 31 373
## 32 754
## 33 1072
## 34 923
## 35 653
## 36 1272
## 37 831
## 38 566
## 39 826
## 40 1151
## 41 880
## 42 542
## 43 823
## 44 1030
## 45 455
## 46 508
## 47 849
Load the outliers library and test for outliers in 3 different ways 1. Is the columns maximum value an outlier? 2. Columns minimum value an outlier 3. Are the smallest and highest values outliers or not? Test Hypothesis H0: There is no outlier in the data. H1: There is an outlier in the data.
library(outliers)
grubbs.test(lastColumnUScrimeData$Crime)
##
## Grubbs test for one outlier
##
## data: lastColumnUScrimeData$Crime
## G = 2.81287, U = 0.82426, p-value = 0.07887
## alternative hypothesis: highest value 1993 is an outlier
grubbs.test(lastColumnUScrimeData$Crime, opposite=TRUE)
##
## Grubbs test for one outlier
##
## data: lastColumnUScrimeData$Crime
## G = 1.45589, U = 0.95292, p-value = 1
## alternative hypothesis: lowest value 342 is an outlier
grubbs.test(lastColumnUScrimeData$Crime, type=11)
##
## Grubbs test for two opposite outliers
##
## data: lastColumnUScrimeData$Crime
## G = 4.26877, U = 0.78103, p-value = 1
## alternative hypothesis: 342 and 1993 are outliers
1.The test (with statistic 2.81287 and p-value 0.07887) shows no strong evidence that 1993 is an outlier. 2.The test (with statistic 1.45589 and p-value 1) shows no strong evidence that 1993 is an outlier. 3.The test (with statistic 4.26877 and p-value 1) shows no strong evidence that 1993 is an outlier.
Based on the 3 test it seems that there shouldn’t be an outlier but if we graph each test with a boxplot we can come to a different conclusion
library(stringr)
possibleoutliers1 <- grubbs.test(lastColumnUScrimeData$Crime)
values1 <- as.numeric(str_extract_all(possibleoutliers1$alternative, "[0-9]+")[[1]])
sub1 <- subset(UScrimeData, Crime %in% values1)
boxplot(lastColumnUScrimeData$Crime,
ylab="Crime")
points(sub1[,ncol(sub1)], pch=1,col='blue')
title(main="Possible Outliers")
possibleoutliers2 <- grubbs.test(lastColumnUScrimeData$Crime, opposite = TRUE)
values2 <- as.numeric(str_extract_all(possibleoutliers2$alternative, "[0-9]+")[[1]])
sub2 <- subset(UScrimeData, Crime %in% values2)
boxplot(lastColumnUScrimeData$Crime,
ylab="Crime")
points(sub2[,ncol(sub2)], pch=1,col='blue')
title(main="Possible Outliers")
possibleoutliers3 <- grubbs.test(lastColumnUScrimeData$Crime, type=11)
values3 <- as.numeric(str_extract_all(possibleoutliers3$alternative, "[0-9]+")[[1]])
sub3 <- subset(UScrimeData, Crime %in% values3)
boxplot(lastColumnUScrimeData$Crime,
ylab="Crime")
points(sub3[,ncol(sub3)], pch=1,col='blue')
title(main="Possible Outliers")
NOTE: Just based on the p-value from the grubbs test it seems that there
are not outliers but once it’s graphed in a boxplot I believe the value
1993 is an outlier since it’s outside of the whiskers of the
boxplot.
| Question 6.1 Describe a situation or problem from your job, everyday life, current events, etc., for which a Change Detection model would be appropriate. Applying the CUSUM technique, how would you choose the critical value and the threshold? |
| Context: An elderly individual living alone wears a smartwatch with embedded sensors (accelerometer, gyroscope) to track their daily activity. I want to use a Change Detection model to monitor their gait patterns and detect early signs of potential falls. |
| Change Detection Task: Identify significant deviations from the individual’s typical gait pattern, which could indicate early signs of weakness, imbalance, or other factors increasing fall risk. |
| Applying CUSUM Technique: 1. Define Reference Pattern: |
| Collect and analyze historical data of the individual’s gait characteristics (e.g., stride length, step time, acceleration, etc.). Calculate the mean and standard deviation for each relevant feature. This sets the baseline “normal” gait pattern. |
| Choose Control Parameter (k): This determines the sensitivity of the model. A lower k detects smaller deviations but increases false positives. Consider factors like individual health status, risk tolerance, and desired response time. |
| Critical Value (H): This determines the level of deviation considered significant. A higher H reduces false positives but risks missing relevant changes. Start with a conservative value and adjust based on model performance. Threshold (G): Triggers an alert if S_max exceeds H + G. Choose G considering the trade-off between timely intervention and avoiding unnecessary alarms. |
Question 6.2 1. Using July through October daily-high-temperature data for Atlanta for 1996 through 2015, use a CUSUM approach to identify when unofficial summer ends (i.e., when the weather starts cooling off) each year. You can get the data that you need from the file temps.txt or online, for example at http://www.iweathernet.com/atlanta-weather-records or https://www.wunderground.com/history/airport/KFTY/2015/7/1/CustomHistory.html . You can use R if you’d like, but it’s straightforward enough that an Excel spreadsheet can easily do the job too. 2. Use a CUSUM approach to make a judgment of whether Atlanta’s summer climate has gotten warmer in that time (and if so, when).
tempData <- read.delim("G:/My Drive/School/GT/ISYE-6501/hw3/temps.txt", header=T)
tempData
## DAY X1996 X1997 X1998 X1999 X2000 X2001 X2002 X2003 X2004 X2005 X2006
## 1 1-Jul 98 86 91 84 89 84 90 73 82 91 93
## 2 2-Jul 97 90 88 82 91 87 90 81 81 89 93
## 3 3-Jul 97 93 91 87 93 87 87 87 86 86 93
## 4 4-Jul 90 91 91 88 95 84 89 86 88 86 91
## 5 5-Jul 89 84 91 90 96 86 93 80 90 89 90
## 6 6-Jul 93 84 89 91 96 87 93 84 90 82 81
## 7 7-Jul 93 75 93 82 96 87 89 87 89 76 80
## 8 8-Jul 91 87 95 86 91 89 89 90 87 88 82
## 9 9-Jul 93 84 95 87 96 91 90 89 88 89 84
## 10 10-Jul 93 87 91 87 99 87 91 84 89 78 84
## 11 11-Jul 90 84 91 82 96 90 84 84 90 83 90
## 12 12-Jul 91 88 86 77 93 90 77 86 89 86 91
## 13 13-Jul 93 86 88 73 91 86 82 87 91 84 91
## 14 14-Jul 93 90 87 81 93 82 88 84 91 87 91
## 15 15-Jul 82 91 91 81 93 82 91 86 84 84 91
## 16 16-Jul 91 91 87 86 93 84 93 88 84 85 91
## 17 17-Jul 96 89 90 82 91 87 93 88 84 89 93
## 18 18-Jul 95 89 91 87 97 88 93 88 87 90 93
## 19 19-Jul 96 89 95 88 100 90 93 88 84 89 96
## 20 20-Jul 99 90 91 90 99 87 91 88 88 89 93
## 21 21-Jul 91 89 91 90 93 84 95 89 89 90 93
## 22 22-Jul 95 84 89 91 96 87 91 86 89 91 91
## 23 23-Jul 91 87 91 93 87 90 89 81 93 91 86
## 24 24-Jul 93 88 91 93 82 84 87 82 95 90 87
## 25 25-Jul 84 89 86 91 75 82 84 84 89 92 88
## 26 26-Jul 84 89 88 93 82 88 86 87 87 94 93
## 27 27-Jul 82 91 80 93 88 90 89 87 84 92 95
## 28 28-Jul 79 91 88 93 91 84 91 89 89 90 96
## 29 29-Jul 90 89 89 93 89 89 91 88 87 83 91
## 30 30-Jul 91 88 90 97 87 89 88 84 89 78 91
## 31 31-Jul 87 72 86 99 86 87 90 88 90 84 94
## 32 1-Aug 86 80 86 96 86 84 93 84 91 82 95
## 33 2-Aug 90 84 82 93 81 84 91 84 90 86 95
## 34 3-Aug 84 88 84 88 84 84 91 84 91 88 97
## 35 4-Aug 91 89 86 89 88 86 91 82 91 91 98
## 36 5-Aug 93 88 90 91 91 88 93 84 90 88 96
## 37 6-Aug 88 84 89 93 91 84 97 82 84 86 89
## 38 7-Aug 91 84 89 93 91 86 87 84 81 80 97
## 39 8-Aug 84 80 86 93 91 88 87 84 82 82 96
## 40 9-Aug 90 73 82 91 96 87 86 86 84 85 95
## 41 10-Aug 89 80 87 90 95 88 88 87 75 83 96
## 42 11-Aug 88 86 88 96 89 86 89 84 82 87 88
## 43 12-Aug 86 88 84 98 89 86 91 81 80 88 84
## 44 13-Aug 84 88 86 97 89 81 91 87 77 86 81
## 45 14-Aug 86 87 80 98 89 87 89 89 82 90 87
## 46 15-Aug 89 88 82 93 94 84 88 90 82 92 86
## 47 16-Aug 90 91 86 93 97 90 90 86 84 89 89
## 48 17-Aug 91 91 84 96 99 91 91 89 86 90 86
## 49 18-Aug 91 89 87 98 101 91 93 90 86 90 88
## 50 19-Aug 90 89 90 98 101 87 91 90 89 89 88
## 51 20-Aug 89 88 79 89 97 86 93 87 88 92 93
## 52 21-Aug 90 82 84 91 87 88 93 88 82 94 91
## 53 22-Aug 91 79 87 91 86 90 91 88 84 93 88
## 54 23-Aug 91 81 87 90 88 88 95 90 84 87 87
## 55 24-Aug 91 82 88 80 92 93 93 89 87 85 83
## 56 25-Aug 84 84 90 82 92 90 91 88 82 84 85
## 57 26-Aug 88 87 91 89 90 91 88 89 86 84 88
## 58 27-Aug 84 90 89 88 90 91 84 90 88 86 88
## 59 28-Aug 86 90 90 90 92 81 82 91 90 86 90
## 60 29-Aug 88 91 93 91 92 86 82 89 87 85 90
## 61 30-Aug 84 91 93 91 88 81 78 88 88 85 88
## 62 31-Aug 82 88 91 84 87 82 77 89 87 85 80
## 63 1-Sep 80 88 87 88 79 80 84 88 82 85 85
## 64 2-Sep 73 91 84 91 81 75 84 86 80 88 86
## 65 3-Sep 87 93 77 84 82 73 89 87 81 87 85
## 66 4-Sep 84 81 90 93 87 81 95 87 82 85 88
## 67 5-Sep 87 81 91 96 81 90 93 84 84 81 83
## 68 6-Sep 89 82 89 96 66 88 91 73 81 81 85
## 69 7-Sep 89 86 90 91 66 87 88 75 86 83 80
## 70 8-Sep 89 88 89 91 75 86 87 81 73 85 83
## 71 9-Sep 91 84 79 77 80 86 91 82 84 86 83
## 72 10-Sep 84 80 78 87 82 89 95 79 84 84 85
## 73 11-Sep 86 82 81 87 84 87 95 80 84 84 84
## 74 12-Sep 88 86 84 87 86 84 90 81 81 86 82
## 75 13-Sep 78 87 89 86 87 84 75 84 79 88 70
## 76 14-Sep 79 87 87 87 86 86 78 82 79 88 80
## 77 15-Sep 86 88 87 89 80 77 91 82 73 91 82
## 78 16-Sep 82 88 88 81 75 77 88 81 75 88 83
## 79 17-Sep 82 90 87 81 73 81 86 81 80 86 85
## 80 18-Sep 78 88 82 82 73 81 81 81 79 88 85
## 81 19-Sep 79 91 80 79 84 82 80 84 78 90 79
## 82 20-Sep 79 95 82 68 87 84 86 87 73 90 73
## 83 21-Sep 78 89 82 79 77 86 84 82 75 90 75
## 84 22-Sep 81 70 88 72 73 87 77 75 80 86 82
## 85 23-Sep 84 80 84 75 81 88 82 81 84 87 86
## 86 24-Sep 84 82 81 78 84 69 73 80 82 88 84
## 87 25-Sep 87 66 82 81 82 66 69 82 81 85 75
## 88 26-Sep 84 70 84 82 68 72 75 82 79 77 78
## 89 27-Sep 79 64 87 78 71 75 75 82 72 86 79
## 90 28-Sep 75 68 80 80 75 78 79 73 78 85 81
## 91 29-Sep 72 77 75 77 73 71 73 66 78 85 70
## 92 30-Sep 64 86 75 71 75 71 79 71 80 82 75
## 93 1-Oct 66 75 86 73 77 75 82 72 82 83 83
## 94 2-Oct 72 73 78 75 79 80 84 68 82 85 81
## 95 3-Oct 84 75 77 84 82 81 84 66 80 83 82
## 96 4-Oct 70 78 82 71 81 80 82 77 81 85 84
## 97 5-Oct 66 81 82 73 82 79 87 78 80 81 86
## 98 6-Oct 64 82 73 71 73 70 86 75 75 72 76
## 99 7-Oct 60 82 82 73 66 68 80 73 75 72 72
## 100 8-Oct 78 82 69 73 55 79 71 73 73 73 72
## 101 9-Oct 70 80 72 72 55 66 66 73 71 70 79
## 102 10-Oct 72 82 73 72 64 73 70 73 71 77 80
## 103 11-Oct 69 82 78 73 71 75 78 66 77 82 80
## 104 12-Oct 69 79 78 70 73 78 84 78 73 74 71
## 105 13-Oct 73 80 78 64 75 78 79 78 64 77 62
## 106 14-Oct 79 68 75 75 75 75 68 78 63 78 69
## 107 15-Oct 81 63 79 73 77 75 57 69 62 79 70
## 108 16-Oct 80 57 78 77 80 62 66 72 71 76 59
## 109 17-Oct 82 66 77 80 80 60 64 68 75 75 71
## 110 18-Oct 66 64 78 71 80 64 68 70 73 81 77
## 111 19-Oct 63 69 82 66 73 71 71 75 68 83 76
## 112 20-Oct 68 70 75 60 73 75 73 78 71 83 69
## 113 21-Oct 79 70 73 64 75 79 71 84 73 80 69
## 114 22-Oct 81 62 63 73 79 80 64 78 73 67 70
## 115 23-Oct 69 63 63 57 75 81 59 78 70 70 53
## 116 24-Oct 73 62 72 59 75 79 68 73 73 56 56
## 117 25-Oct 73 75 75 64 78 73 60 73 78 54 55
## 118 26-Oct 75 71 79 69 75 64 68 68 79 61 62
## 119 27-Oct 75 57 79 75 78 51 69 64 81 63 66
## 120 28-Oct 81 55 79 73 80 55 75 57 78 62 63
## 121 29-Oct 82 64 78 72 75 63 75 70 75 64 72
## 122 30-Oct 82 66 82 75 77 72 68 77 78 69 73
## 123 31-Oct 81 60 79 75 78 71 60 75 82 70 68
## X2007 X2008 X2009 X2010 X2011 X2012 X2013 X2014 X2015
## 1 95 85 95 87 92 105 82 90 85
## 2 85 87 90 84 94 93 85 93 87
## 3 82 91 89 83 95 99 76 87 79
## 4 86 90 91 85 92 98 77 84 85
## 5 88 88 80 88 90 100 83 86 84
## 6 87 82 87 89 90 98 83 87 84
## 7 82 88 86 94 94 93 79 89 90
## 8 82 90 82 97 94 95 88 90 90
## 9 89 89 84 96 91 97 88 90 91
## 10 86 87 84 90 92 95 87 87 93
## 11 85 89 86 93 95 90 80 85 92
## 12 87 93 90 90 95 84 87 90 93
## 13 86 85 84 91 97 90 78 89 92
## 14 84 88 89 91 90 90 85 90 90
## 15 81 89 89 94 80 90 86 86 89
## 16 86 89 90 89 85 92 87 83 88
## 17 89 88 88 87 87 93 91 86 93
## 18 89 90 82 83 89 93 87 82 92
## 19 88 91 80 90 94 91 90 85 91
## 20 86 94 82 91 91 84 86 76 93
## 21 86 95 86 94 92 90 87 82 93
## 22 79 92 84 95 94 95 85 83 92
## 23 82 87 87 97 92 97 84 88 88
## 24 87 88 88 94 92 97 86 87 91
## 25 87 89 90 95 90 98 89 88 90
## 26 87 87 92 95 94 98 86 89 91
## 27 90 90 90 93 94 97 82 92 92
## 28 89 93 89 90 90 97 86 90 94
## 29 87 92 85 94 93 94 86 82 93
## 30 92 90 82 95 96 96 90 84 94
## 31 90 88 85 95 96 88 80 85 93
## 32 92 89 89 96 91 94 87 81 89
## 33 92 92 83 84 96 99 89 84 94
## 34 94 91 90 92 97 94 88 88 94
## 35 97 91 92 95 85 87 90 90 97
## 36 96 92 92 93 96 90 88 89 95
## 37 98 94 89 93 93 86 88 92 88
## 38 98 90 91 91 93 84 86 95 88
## 39 100 86 92 93 94 92 83 90 92
## 40 103 85 93 94 91 88 89 89 93
## 41 103 85 93 94 95 87 90 86 94
## 42 100 88 95 95 94 85 90 83 91
## 43 90 81 86 95 95 88 90 88 90
## 44 100 81 90 96 95 91 89 84 89
## 45 99 84 90 89 94 88 83 85 90
## 46 102 87 90 90 88 85 73 87 90
## 47 101 86 88 90 90 91 67 88 90
## 48 101 85 87 91 92 87 66 89 89
## 49 97 86 88 93 94 87 77 89 88
## 50 95 90 90 92 96 84 82 86 89
## 51 96 90 88 93 93 84 84 89 88
## 52 99 85 88 93 94 88 84 92 89
## 53 104 82 85 94 98 84 88 93 92
## 54 98 78 81 93 92 88 90 93 87
## 55 95 83 86 90 93 86 84 88 89
## 56 94 78 87 89 95 85 82 84 84
## 57 92 83 90 90 99 90 82 86 86
## 58 88 80 83 89 95 90 86 88 85
## 59 88 86 75 87 95 80 90 91 83
## 60 89 89 86 84 93 86 92 92 81
## 61 89 89 79 85 90 80 87 88 74
## 62 86 88 79 89 92 89 90 89 84
## 63 84 81 71 90 95 91 90 90 87
## 64 83 85 78 91 96 89 84 90 90
## 65 88 83 79 92 95 85 90 92 89
## 66 91 85 83 84 80 77 89 82 92
## 67 89 88 83 85 78 85 89 89 87
## 68 85 87 85 90 75 85 88 91 85
## 69 86 89 84 91 69 92 88 90 85
## 70 88 90 87 93 73 88 91 84 84
## 71 89 88 84 92 81 83 90 84 87
## 72 89 87 80 94 84 84 89 86 85
## 73 89 83 75 96 86 83 89 90 86
## 74 86 87 81 89 87 81 90 92 78
## 75 85 86 80 86 89 81 87 86 75
## 76 81 88 82 91 92 83 82 78 77
## 77 82 79 79 91 86 87 84 80 80
## 78 76 80 82 89 72 86 89 86 79
## 79 78 69 73 95 79 83 79 86 83
## 80 79 82 80 93 77 79 78 85 83
## 81 82 81 74 92 77 81 84 84 87
## 82 81 79 81 96 82 79 86 83 89
## 83 78 75 79 95 86 85 73 87 77
## 84 86 84 84 92 80 87 82 82 76
## 85 83 82 83 91 83 81 82 77 81
## 86 89 78 85 88 82 78 71 78 74
## 87 87 82 87 93 88 82 67 77 67
## 88 84 80 85 76 86 86 78 74 71
## 89 85 77 80 81 84 88 79 78 71
## 90 85 86 83 76 79 86 77 74 75
## 91 81 86 72 79 84 84 76 71 77
## 92 79 86 74 76 78 72 77 84 85
## 93 80 74 76 79 65 75 82 86 71
## 94 82 74 75 78 68 72 82 85 66
## 95 77 80 76 68 75 74 82 78 66
## 96 80 83 74 67 80 82 85 65 70
## 97 81 83 62 70 83 82 84 71 73
## 98 82 82 71 73 81 83 84 78 76
## 99 83 82 79 81 79 68 74 82 81
## 100 83 72 80 82 78 63 72 86 82
## 101 81 75 85 85 72 70 76 86 81
## 102 81 77 74 86 68 73 80 86 71
## 103 67 78 77 86 65 75 79 86 73
## 104 72 77 66 80 73 79 81 85 76
## 105 74 77 73 80 74 75 82 85 81
## 106 78 80 66 73 77 77 77 75 78
## 107 78 81 61 78 80 77 68 69 81
## 108 76 83 61 76 84 74 74 70 77
## 109 82 69 51 80 85 75 72 80 70
## 110 77 67 55 78 80 74 73 76 66
## 111 76 65 61 82 67 73 63 73 64
## 112 75 66 68 77 59 71 70 73 71
## 113 78 72 71 80 63 76 72 77 76
## 114 72 68 74 78 68 79 69 70 79
## 115 81 62 72 76 70 78 63 72 81
## 116 59 54 69 81 73 79 66 74 76
## 117 61 67 65 76 76 80 56 77 71
## 118 68 70 65 85 77 80 61 84 67
## 119 67 59 60 76 79 70 69 84 56
## 120 70 50 71 74 74 56 64 77 78
## 121 62 59 75 68 59 56 75 73 70
## 122 67 65 66 71 61 56 78 68 70
## 123 71 67 69 75 65 65 74 63 62
tempDataAvg <- rowMeans(tempData[c(2:length(tempData))],
#Which dimensions are regarded as rows or columns to sum over. For row*, the sum or mean is over dimensions dims+1, ...; for col* it is over dimensions 1:dims
dims=1,
#logical. Should missing values (including NaN) be omitted from the calculations?
na.rm=T)
dateAvgMean_ <- mean(tempDataAvg)
dateMinusMean <- tempDataAvg - dateAvgMean_
# set C
C <- 4
dateMinusMeanMinusC <- dateMinusMean - C
FirstCsum <- 0 * dateMinusMeanMinusC
Csum <- append(FirstCsum, 0)
for (t in 1:length(dateMinusMeanMinusC))
{comparison <- Csum[t] + dateMinusMeanMinusC[t]
ifelse(comparison > 0, Csum[t+1] <- comparison, Csum[t+1] <- 0)
}
plot(Csum)
which(Csum >= 85)
## [1] 56 58 59 60 61
tempData[56,1]
## [1] "25-Aug"
To get a general idea of Atlanta’s summer temperature trends, I calculated the average daily temperature for every date across all years. By examining various critical values and their impact on visualizations, I found that with a critical value of 4 and a threshold of 85 degrees Fahrenheit, Atlanta’s summer heat typically starts to ease around August 25th, on average.
Question 6.2.2 I computed the mean annual temperature from the data and performed a CUSUM analysis to detect changes in temperature over time as seen on sheet1. Based on the graph I don’t think the summer’s got any hotter.