ISYA 6501 Week 3 Homework
Question 5.1
Hide
# clear env
rm(list = ls())
# import packages
library(outliers)
set.seed(12)
uscrime
ISYA 6501 Week 3 Homework
Question 5.1
Hide
# clear env
rm(list = ls())
# import packages
library(outliers)
set.seed(12)
uscrime <- read.table("/Users/wstamatis/OMSA/ISYE 6501/Week 3 Homework/uscrim
e.txt",
stringsAsFactors = FALSE, header = TRUE)
temps <- read.table("/Users/wstamatis/OMSA/ISYE 6501/Week 3 Homework/temps.tx
t",
stringsAsFactors = FALSE, header = TRUE)
# check for outliers using grubbs.test
grubbs.test(uscrime$Crime)
Grubbs test for one outlier
data: uscrime$Crime
G = 2.81290, U = 0.82426, p-value = 0.07887
alternative hypothesis: highest value 1993 is an outlier
Hide
# verify with a five-number summary
summary(uscrime$Crime)
Min. 1st Qu. Median Mean 3rd Qu. Max.
This study source was downloaded by 100000839632511 from CourseHero.com on 05-13-2022 05:49:39 GMT -05:00
https://www.coursehero.com/file/39779415/ISYE6501-Homework-3-Solutionpdf/342.0 658.5 831.0 905.1 1057.5 1993.0
Hide
# visualize
plot(uscrime$Crime)
Hide
uscrime$Crime[0:10]
[1] 791 1635 578 1969 1234 682 963 1555 856 705
We see that 1993 is the clearest outlier, with 1969 being a close second.
Question 6.1
I work for an EdTech platform, and tracking active users is a very important metric for us. We want to be
able to reach out to schools that aren’t using our product BEFORE we lose them, and applying the
CUSUM approach we can detect schools that are at risk of dropping and reach out to them. To be honest,
I would experiment a little to find an accurate critical value and threshold. To start out, I would choose a
relatively critical value and low threshold. I would gradually increase the threshold until we noticed that
we actually started losing accounts, at which point I would adjust to find some stability.
This study source was downloaded by 100000839632511 from CourseHero.com on 05-13-2022 05:49:39 GMT -05:00
https://www.coursehero.com/file/39779415/ISYE6501-Homework-3-Solutionpdf/Question 6.2.1
Using July through October daily-hightemperature 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.
For this question, I chose to average out the temperature for each day across all years. This gave me the
best insight into general trends in Atlanta summer. I varied the critical value (and visualized in order to
choose a threshold) and determined that, with a C = 4 and a threshold of 85, the weather begins to cool
off (on average) on August 25th.
Hide
# average the temperature for each day across the years
date_avgs <- rowMeans(temps[c(2:length(temps))], dims=1, na.rm=T)
# compute the mean of the (now averaged) time series
da_mu <- mean(date_avgs)
# compute the difference between the mean of the time series and each "day"
da_minus_mu <- date_avgs - da_mu
# set C
C <- 4
# subtract C from the difference score
damimu_minus_C <- da_minus_mu - C
# create an empty vector for looping
# include an additional zero to help with indexing