diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5b6a065 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.Rproj.user +.Rhistory +.RData +.Ruserdata diff --git a/class4 - Swirl.Rproj b/class4 - Swirl.Rproj new file mode 100644 index 0000000..8e3c2eb --- /dev/null +++ b/class4 - Swirl.Rproj @@ -0,0 +1,13 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX diff --git a/lesson1.csv b/lesson1.csv new file mode 100644 index 0000000..7768221 --- /dev/null +++ b/lesson1.csv @@ -0,0 +1,1912 @@ +"time","answer","id" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","par(mfrow=c(1,1))","YOUR NAME" +"0","cor(bct, oct)","YOUR NAME" +"0","plot(bct, oct, main = ""Plot of Bike Count vs Other Count"")","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","pmod_bike <- glm(bct ~ type + bike + type","YOUR NAME" +"bike, family = poisson(link = log), data = bikedf)","","YOUR NAME" +"0","summary(pmod_bike)","YOUR NAME" +"0","pmod_other <- glm(oct ~ type + bike + type","YOUR NAME" +"bike, family = poisson(link=log), data = bikedf)","","YOUR NAME" +"0","summary(pmod_other)","YOUR NAME" +"0","int <- aov(bct ~ type*bike)","YOUR NAME" +"0","summary(int)","YOUR NAME" +"0","","YOUR NAME" +"0","catgr1<- c(12, 1, 2, 4, 9, 7, 9, 8)","YOUR NAME" +"0","catgr2<- c(113, 18, 14, 44, 208, 67, 29, 154)","YOUR NAME" +"0","M <- median(catgr1)","YOUR NAME" +"0","M2 <- median(catgr2)","YOUR NAME" +"0","","YOUR NAME" +"0","type <- c(rep(""Residential"", 20), rep(""Side"", 20), rep(""Main"", 20))","YOUR NAME" +"0","bike <- c(rep(c(rep(1, 10), rep(0, 10)), 3))","YOUR NAME" +"0","bct <- c(16, 9, 10, 13, 19, 20, 18, 17, 35, 55,","YOUR NAME" +"0","12, 1, 2, 4, 9, 7, 9, 8, M, M, 8, 35, 31,","YOUR NAME" +"0","19, 38, 47, 44, 44, 29, 18, 10, 43, 5,","YOUR NAME" +"0","14, 58, 15, 0, 47, 51, 32, 60, 51, 58,","YOUR NAME" +"0","59, 53, 68, 68, 60, 71, 63, 8, 9, 6,","YOUR NAME" +"0","9, 19, 61, 31, 75, 14, 25)","YOUR NAME" +"0","oct <- c(58, 90, 48, 57, 103, 57, 86, 112, 273, 64,","YOUR NAME" +"0","113, 18, 14, 44, 208, 67, 29, 154, M2, M2,","YOUR NAME" +"0","29, 415, 425, 42, 180, 675, 620, 437, 47, 462,","YOUR NAME" +"0","557, 1258, 499, 601, 1163, 700, 90, 1093, 1459, 1086,","YOUR NAME" +"0","1545, 1499, 1598, 503, 407, 1494, 1558, 1706, 476, 752,","YOUR NAME" +"0","1248, 1246, 1596, 1765, 1290, 2498, 2346, 3101, 1918, 2318)","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","mean(bct)","YOUR NAME" +"0","mean(bct[bike == 1])","YOUR NAME" +"0","mean(bct[bike == 0])","YOUR NAME" +"0","par(mfrow=c(1,2))","YOUR NAME" +"0","hist(bct[bike == 1])","YOUR NAME" +"0","hist(bct[bike == 0])","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","anova(lm(bct ~ type * bike, data = bikedf))","YOUR NAME" +"0","anova(lm(oct ~ type * bike, data = bikedf))","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","par(mfrow=c(1,1))","YOUR NAME" +"0","cor(bct, oct)","YOUR NAME" +"0","plot(bct, oct, main = ""Plot of Bike Count vs Other Count"")","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","int <- aov(bct ~ type*bike)","YOUR NAME" +"0","summary(int)","YOUR NAME" +"0","","YOUR NAME" +"0","catgr1<- c(12, 1, 2, 4, 9, 7, 9, 8)","YOUR NAME" +"0","catgr2<- c(113, 18, 14, 44, 208, 67, 29, 154)","YOUR NAME" +"0","M <- median(catgr1)","YOUR NAME" +"0","M2 <- median(catgr2)","YOUR NAME" +"0","","YOUR NAME" +"0","type <- c(rep(""Residential"", 20), rep(""Side"", 20), rep(""Main"", 20))","YOUR NAME" +"0","bike <- c(rep(c(rep(1, 10), rep(0, 10)), 3))","YOUR NAME" +"0","bct <- c(16, 9, 10, 13, 19, 20, 18, 17, 35, 55,","YOUR NAME" +"0","12, 1, 2, 4, 9, 7, 9, 8, M, M, 8, 35, 31,","YOUR NAME" +"0","19, 38, 47, 44, 44, 29, 18, 10, 43, 5,","YOUR NAME" +"0","14, 58, 15, 0, 47, 51, 32, 60, 51, 58,","YOUR NAME" +"0","59, 53, 68, 68, 60, 71, 63, 8, 9, 6,","YOUR NAME" +"0","9, 19, 61, 31, 75, 14, 25)","YOUR NAME" +"0","oct <- c(58, 90, 48, 57, 103, 57, 86, 112, 273, 64,","YOUR NAME" +"0","113, 18, 14, 44, 208, 67, 29, 154, M2, M2,","YOUR NAME" +"0","29, 415, 425, 42, 180, 675, 620, 437, 47, 462,","YOUR NAME" +"0","557, 1258, 499, 601, 1163, 700, 90, 1093, 1459, 1086,","YOUR NAME" +"0","1545, 1499, 1598, 503, 407, 1494, 1558, 1706, 476, 752,","YOUR NAME" +"0","1248, 1246, 1596, 1765, 1290, 2498, 2346, 3101, 1918, 2318)","YOUR NAME" +"0","bikedf$bike <- as.factor(bikedf$bike)","YOUR NAME" +"0","is.factor(bikedf$bike)","YOUR NAME" +"0","attach(bikedf)","YOUR NAME" +"0","mean(bct)","YOUR NAME" +"0","mean(bct[bike == 1])","YOUR NAME" +"0","mean(bct[bike == 0])","YOUR NAME" +"0","par(mfrow=c(1,2))","YOUR NAME" +"0","hist(bct[bike == 1])","YOUR NAME" +"0","hist(bct[bike == 0])","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","anova(lm(bct ~ type * bike, data = bikedf))","YOUR NAME" +"0","anova(lm(oct ~ type * bike, data = bikedf))","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","par(mfrow=c(1,1))","YOUR NAME" +"0","cor(bct, oct)","YOUR NAME" +"0","plot(bct, oct, main = ""Plot of Bike Count vs Other Count"")","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","int <- aov(bct ~ type*bike)","YOUR NAME" +"0","summary(int)","YOUR NAME" +"0","","YOUR NAME" +"0","catgr1<- c(12, 1, 2, 4, 9, 7, 9, 8)","YOUR NAME" +"0","catgr2<- c(113, 18, 14, 44, 208, 67, 29, 154)","YOUR NAME" +"0","M <- median(catgr1)","YOUR NAME" +"0","M2 <- median(catgr2)","YOUR NAME" +"0","","YOUR NAME" +"0","type <- c(rep(""Residential"", 20), rep(""Side"", 20), rep(""Main"", 20))","YOUR NAME" +"0","bike <- c(rep(c(rep(1, 10), rep(0, 10)), 3))","YOUR NAME" +"0","bct <- c(16, 9, 10, 13, 19, 20, 18, 17, 35, 55,","YOUR NAME" +"0","12, 1, 2, 4, 9, 7, 9, 8, M, M, 8, 35, 31,","YOUR NAME" +"0","19, 38, 47, 44, 44, 29, 18, 10, 43, 5,","YOUR NAME" +"0","14, 58, 15, 0, 47, 51, 32, 60, 51, 58,","YOUR NAME" +"0","59, 53, 68, 68, 60, 71, 63, 8, 9, 6,","YOUR NAME" +"0","9, 19, 61, 31, 75, 14, 25)","YOUR NAME" +"0","oct <- c(58, 90, 48, 57, 103, 57, 86, 112, 273, 64,","YOUR NAME" +"0","113, 18, 14, 44, 208, 67, 29, 154, M2, M2,","YOUR NAME" +"0","29, 415, 425, 42, 180, 675, 620, 437, 47, 462,","YOUR NAME" +"0","557, 1258, 499, 601, 1163, 700, 90, 1093, 1459, 1086,","YOUR NAME" +"0","1545, 1499, 1598, 503, 407, 1494, 1558, 1706, 476, 752,","YOUR NAME" +"0","1248, 1246, 1596, 1765, 1290, 2498, 2346, 3101, 1918, 2318)","YOUR NAME" +"0","mean(bct)","YOUR NAME" +"0","mean(bct[bike == 1])","YOUR NAME" +"0","mean(bct[bike == 0])","YOUR NAME" +"0","par(mfrow=c(1,2))","YOUR NAME" +"0","hist(bct[bike == 1])","YOUR NAME" +"0","hist(bct[bike == 0])","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","par(mfrow=c(1,1))","YOUR NAME" +"0","cor(bct, oct)","YOUR NAME" +"0","plot(bct, oct, main = ""Plot of Bike Count vs Other Count"")","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","int <- aov(bct ~ type*bike)","YOUR NAME" +"0","summary(int)","YOUR NAME" +"0","","YOUR NAME" +"0","catgr1<- c(12, 1, 2, 4, 9, 7, 9, 8)","YOUR NAME" +"0","catgr2<- c(113, 18, 14, 44, 208, 67, 29, 154)","YOUR NAME" +"0","M <- median(catgr1)","YOUR NAME" +"0","M2 <- median(catgr2)","YOUR NAME" +"0","","YOUR NAME" +"0","type <- c(rep(""Residential"", 20), rep(""Side"", 20), rep(""Main"", 20))","YOUR NAME" +"0","bike <- c(rep(c(rep(1, 10), rep(0, 10)), 3))","YOUR NAME" +"0","bct <- c(16, 9, 10, 13, 19, 20, 18, 17, 35, 55,","YOUR NAME" +"0","12, 1, 2, 4, 9, 7, 9, 8, M, M, 8, 35, 31,","YOUR NAME" +"0","19, 38, 47, 44, 44, 29, 18, 10, 43, 5,","YOUR NAME" +"0","14, 58, 15, 0, 47, 51, 32, 60, 51, 58,","YOUR NAME" +"0","59, 53, 68, 68, 60, 71, 63, 8, 9, 6,","YOUR NAME" +"0","9, 19, 61, 31, 75, 14, 25)","YOUR NAME" +"0","oct <- c(58, 90, 48, 57, 103, 57, 86, 112, 273, 64,","YOUR NAME" +"0","113, 18, 14, 44, 208, 67, 29, 154, M2, M2,","YOUR NAME" +"0","29, 415, 425, 42, 180, 675, 620, 437, 47, 462,","YOUR NAME" +"0","557, 1258, 499, 601, 1163, 700, 90, 1093, 1459, 1086,","YOUR NAME" +"0","1545, 1499, 1598, 503, 407, 1494, 1558, 1706, 476, 752,","YOUR NAME" +"0","1248, 1246, 1596, 1765, 1290, 2498, 2346, 3101, 1918, 2318)","YOUR NAME" +"0","mean(bct)","YOUR NAME" +"0","mean(bct[bike == 1])","YOUR NAME" +"0","mean(bct[bike == 0])","YOUR NAME" +"0","par(mfrow=c(1,2))","YOUR NAME" +"0","hist(bct[bike == 1])","YOUR NAME" +"0","hist(bct[bike == 0])","YOUR NAME" +"0","missingrow <- c(12, 1, 2, 4, 9, 7, 9, 8)","YOUR NAME" +"0","missingrow2 <- c(113, 18, 14, 44, 208, 67, 29, 154)","YOUR NAME" +"0","M <- median(missingrow)","YOUR NAME" +"0","M2 <- median(missingrow2)","YOUR NAME" +"0","type <- c(rep(""Residential"", 20), rep(""Side"", 20), rep(""Main"", 20))","YOUR NAME" +"0","bike <- c(rep(c(rep(1, 10), rep(0, 10)), 3))","YOUR NAME" +"0","bikect <- c(16, 9, 10, 13, 19, 20, 18, 17, 35, 55,","YOUR NAME" +"0","12, 1, 2, 4, 9, 7, 9, 8, M, M, 8, 35, 31,","YOUR NAME" +"0","19, 38, 47, 44, 44, 29, 18, 10, 43, 5,","YOUR NAME" +"0","14, 58, 15, 0, 47, 51, 32, 60, 51, 58,","YOUR NAME" +"0","59, 53, 68, 68, 60, 71, 63, 8, 9, 6,","YOUR NAME" +"0","9, 19, 61, 31, 75, 14, 25)","YOUR NAME" +"0","otherct <- c(58, 90, 48, 57, 103, 57, 86, 112, 273, 64,","YOUR NAME" +"0","113, 18, 14, 44, 208, 67, 29, 154, M2, M2,","YOUR NAME" +"0","29, 415, 425, 42, 180, 675, 620, 437, 47, 462,","YOUR NAME" +"0","557, 1258, 499, 601, 1163, 700, 90, 1093, 1459, 1086,","YOUR NAME" +"0","1545, 1499, 1598, 503, 407, 1494, 1558, 1706, 476, 752,","YOUR NAME" +"0","1248, 1246, 1596, 1765, 1290, 2498, 2346, 3101, 1918, 2318)","YOUR NAME" +"0","bikedf$bike <- as.factor(bikedf$bike)","YOUR NAME" +"0","is.factor(bikedf$bike)","YOUR NAME" +"0","attach(bikedf)","YOUR NAME" +"0","mean(bikect)","YOUR NAME" +"0","mean(bikect[bike == 1])","YOUR NAME" +"0","mean(bikect[bike == 0])","YOUR NAME" +"0","par(mfrow=c(1,2))","YOUR NAME" +"0","hist(bikect[bike == 1])","YOUR NAME" +"0","hist(bikect[bike == 0])","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","anova(lm(bikect ~ type * bike, data = bikedf))","YOUR NAME" +"0","anova(lm(otherct ~ type * bike, data = bikedf))","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","par(mfrow=c(1,1))","YOUR NAME" +"0","cor(bikect, otherct)","YOUR NAME" +"0","plot(bikect, otherct, main = ""Plot of Bike Count vs Other Count"")","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","pmod_bike <- glm(bikect ~ type + bike + type","YOUR NAME" +"bike, family = poisson(link = log), data = bikedf)","","YOUR NAME" +"0","summary(pmod_bike)","YOUR NAME" +"0","pmod_other <- glm(otherct ~ type + bike + type","YOUR NAME" +"bike, family = poisson(link=log), data = bikedf)","","YOUR NAME" +"0","summary(pmod_other)","YOUR NAME" +"0","int <- aov(bikect ~ type*bike)","YOUR NAME" +"0","summary(int)","YOUR NAME" +"0","pmod_bike <- glm(bct ~ type + bike + type","YOUR NAME" +"bike, family = poisson(link = log), data = bikedf)","","YOUR NAME" +"0","summary(pmod_bike)","YOUR NAME" +"0","pmod_other <- glm(oct ~ type + bike + type","YOUR NAME" +"bike, family = poisson(link=log), data = bikedf)","","YOUR NAME" +"0","summary(pmod_other)","YOUR NAME" +"0","int <- aov(bct ~ type*bike)","YOUR NAME" +"0","summary(int)","YOUR NAME" +"0","missingrow <- c(12, 1, 2, 4, 9, 7, 9, 8)","YOUR NAME" +"0","missingrow2 <- c(113, 18, 14, 44, 208, 67, 29, 154)","YOUR NAME" +"0","M <- median(missingrow)","YOUR NAME" +"0","M2 <- median(missingrow2)","YOUR NAME" +"0","type <- c(rep(""Residential"", 20), rep(""Side"", 20), rep(""Main"", 20))","YOUR NAME" +"0","bike <- c(rep(c(rep(1, 10), rep(0, 10)), 3))","YOUR NAME" +"0","bikect <- c(16, 9, 10, 13, 19, 20, 18, 17, 35, 55,","YOUR NAME" +"0","12, 1, 2, 4, 9, 7, 9, 8, M, M, 8, 35, 31,","YOUR NAME" +"0","19, 38, 47, 44, 44, 29, 18, 10, 43, 5,","YOUR NAME" +"0","14, 58, 15, 0, 47, 51, 32, 60, 51, 58,","YOUR NAME" +"0","59, 53, 68, 68, 60, 71, 63, 8, 9, 6,","YOUR NAME" +"0","9, 19, 61, 31, 75, 14, 25)","YOUR NAME" +"0","otherct <- c(58, 90, 48, 57, 103, 57, 86, 112, 273, 64,","YOUR NAME" +"0","113, 18, 14, 44, 208, 67, 29, 154, M2, M2,","YOUR NAME" +"0","29, 415, 425, 42, 180, 675, 620, 437, 47, 462,","YOUR NAME" +"0","557, 1258, 499, 601, 1163, 700, 90, 1093, 1459, 1086,","YOUR NAME" +"0","1545, 1499, 1598, 503, 407, 1494, 1558, 1706, 476, 752,","YOUR NAME" +"0","1248, 1246, 1596, 1765, 1290, 2498, 2346, 3101, 1918, 2318)","YOUR NAME" +"0","bikedf$bike <- as.factor(bikedf$bike)","YOUR NAME" +"0","is.factor(bikedf$bike)","YOUR NAME" +"0","attach(bikedf)","YOUR NAME" +"0","mean(bikect)","YOUR NAME" +"0","mean(bikect[bike == 1])","YOUR NAME" +"0","mean(bikect[bike == 0])","YOUR NAME" +"0","par(mfrow=c(1,2))","YOUR NAME" +"0","hist(bikect[bike == 1])","YOUR NAME" +"0","hist(bikect[bike == 0])","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","anova(lm(bikect ~ type * bike, data = bikedf))","YOUR NAME" +"0","anova(lm(otherct ~ type * bike, data = bikedf))","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","par(mfrow=c(1,1))","YOUR NAME" +"0","cor(bikect, otherct)","YOUR NAME" +"0","plot(bikect, otherct, main = ""Plot of Bike Count vs Other Count"")","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","pmod_bike <- glm(bikect ~ type + bike + type","YOUR NAME" +"bike, family = poisson(link = log), data = bikedf)","","YOUR NAME" +"0","summary(pmod_bike)","YOUR NAME" +"0","pmod_other <- glm(otherct ~ type + bike + type","YOUR NAME" +"bike, family = poisson(link=log), data = bikedf)","","YOUR NAME" +"0","summary(pmod_other)","YOUR NAME" +"0","int <- aov(bikect ~ type*bike)","YOUR NAME" +"0","summary(int)","YOUR NAME" +"0","","YOUR NAME" +"0","catgr1<- c(12, 1, 2, 4, 9, 7, 9, 8)","YOUR NAME" +"0","catgr2<- c(113, 18, 14, 44, 208, 67, 29, 154)","YOUR NAME" +"0","M <- median(catgr1)","YOUR NAME" +"0","M2 <- median(catgr2)","YOUR NAME" +"0","","YOUR NAME" +"0","type <- c(rep(""Residential"", 20), rep(""Side"", 20), rep(""Main"", 20))","YOUR NAME" +"0","bike <- c(rep(c(rep(1, 10), rep(0, 10)), 3))","YOUR NAME" +"0","bct <- c(16, 9, 10, 13, 19, 20, 18, 17, 35, 55,","YOUR NAME" +"0","12, 1, 2, 4, 9, 7, 9, 8, M, M, 8, 35, 31,","YOUR NAME" +"0","19, 38, 47, 44, 44, 29, 18, 10, 43, 5,","YOUR NAME" +"0","14, 58, 15, 0, 47, 51, 32, 60, 51, 58,","YOUR NAME" +"0","59, 53, 68, 68, 60, 71, 63, 8, 9, 6,","YOUR NAME" +"0","9, 19, 61, 31, 75, 14, 25)","YOUR NAME" +"0","oct <- c(58, 90, 48, 57, 103, 57, 86, 112, 273, 64,","YOUR NAME" +"0","113, 18, 14, 44, 208, 67, 29, 154, M2, M2,","YOUR NAME" +"0","29, 415, 425, 42, 180, 675, 620, 437, 47, 462,","YOUR NAME" +"0","557, 1258, 499, 601, 1163, 700, 90, 1093, 1459, 1086,","YOUR NAME" +"0","1545, 1499, 1598, 503, 407, 1494, 1558, 1706, 476, 752,","YOUR NAME" +"0","1248, 1246, 1596, 1765, 1290, 2498, 2346, 3101, 1918, 2318)","YOUR NAME" +"0","bikedf <- data.frame(type, bike, bct, oct)","YOUR NAME" +"0","bikedf$bike <- as.factor(bikedf$bike)","YOUR NAME" +"0","is.factor(bikedf$bike)","YOUR NAME" +"0","attach(bikedf)","YOUR NAME" +"0","mean(bct)","YOUR NAME" +"0","mean(bct[bike == 1])","YOUR NAME" +"0","mean(bct[bike == 0])","YOUR NAME" +"0","par(mfrow=c(1,2))","YOUR NAME" +"0","hist(bct[bike == 1])","YOUR NAME" +"0","hist(bct[bike == 0])","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","par(mfrow=c(1,1))","YOUR NAME" +"0","cor(bct, oct)","YOUR NAME" +"0","plot(bct, oct, main = ""Plot of Bike Count vs Other Count"")","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","pmod_bike <- glm(bct ~ type + bike + type","YOUR NAME" +"bike, family = poisson(link = log), data = bikedf)","","YOUR NAME" +"0","summary(pmod_bike)","YOUR NAME" +"0","pmod_other <- glm(oct ~ type + bike + type","YOUR NAME" +"bike, family = poisson(link=log), data = bikedf)","","YOUR NAME" +"0","summary(pmod_other)","YOUR NAME" +"0","int <- aov(bct ~ type*bike)","YOUR NAME" +"0","summary(int)","YOUR NAME" +"0","","YOUR NAME" +"0","par(mfrow=c(1,2))","YOUR NAME" +"0","hist(bct[bike == 1])","YOUR NAME" +"0","hist(bct[bike == 0])","YOUR NAME" +"0","anova(lm(bikect ~ type * bike, data = bikedf))","YOUR NAME" +"0","anova(lm(otherct ~ type * bike, data = bikedf))","YOUR NAME" +"0","","YOUR NAME" +"0","catgr1<- c(12, 1, 2, 4, 9, 7, 9, 8)","YOUR NAME" +"0","catgr2<- c(113, 18, 14, 44, 208, 67, 29, 154)","YOUR NAME" +"0","M <- median(catgr1)","YOUR NAME" +"0","M2 <- median(catgr2)","YOUR NAME" +"0","","YOUR NAME" +"0","type <- c(rep(""Residential"", 20), rep(""Side"", 20), rep(""Main"", 20))","YOUR NAME" +"0","bike <- c(rep(c(rep(1, 10), rep(0, 10)), 3))","YOUR NAME" +"0","bct <- c(16, 9, 10, 13, 19, 20, 18, 17, 35, 55,","YOUR NAME" +"0","12, 1, 2, 4, 9, 7, 9, 8, M, M, 8, 35, 31,","YOUR NAME" +"0","19, 38, 47, 44, 44, 29, 18, 10, 43, 5,","YOUR NAME" +"0","14, 58, 15, 0, 47, 51, 32, 60, 51, 58,","YOUR NAME" +"0","59, 53, 68, 68, 60, 71, 63, 8, 9, 6,","YOUR NAME" +"0","9, 19, 61, 31, 75, 14, 25)","YOUR NAME" +"0","oct <- c(58, 90, 48, 57, 103, 57, 86, 112, 273, 64,","YOUR NAME" +"0","113, 18, 14, 44, 208, 67, 29, 154, M2, M2,","YOUR NAME" +"0","29, 415, 425, 42, 180, 675, 620, 437, 47, 462,","YOUR NAME" +"0","557, 1258, 499, 601, 1163, 700, 90, 1093, 1459, 1086,","YOUR NAME" +"0","1545, 1499, 1598, 503, 407, 1494, 1558, 1706, 476, 752,","YOUR NAME" +"0","1248, 1246, 1596, 1765, 1290, 2498, 2346, 3101, 1918, 2318)","YOUR NAME" +"0","bikedf <- data.frame(type, bike, bct, oct)","YOUR NAME" +"0","bikedf$bike <- as.factor(bikedf$bike)","YOUR NAME" +"0","is.factor(bikedf$bike)","YOUR NAME" +"0","attach(bikedf)","YOUR NAME" +"0","par(mfrow=c(1,2))","YOUR NAME" +"0","hist(bct[bike == 1])","YOUR NAME" +"0","hist(bct[bike == 0])","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","anova(lm(bct ~ type * bike, data = bikedf))","YOUR NAME" +"0","anova(lm(oct ~ type * bike, data = bikedf))","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","pmod_bike <- glm(bct ~ type + bike + type","YOUR NAME" +"bike, family = poisson(link = log), data = bikedf)","","YOUR NAME" +"0","summary(pmod_bike)","YOUR NAME" +"0","pmod_other <- glm(oct ~ type + bike + type","YOUR NAME" +"bike, family = poisson(link=log), data = bikedf)","","YOUR NAME" +"0","summary(pmod_other)","YOUR NAME" +"0","","YOUR NAME" +"0","","YOUR NAME" +"0","int <- aov(bct ~ type*bike)","YOUR NAME" +"0","summary(int)","YOUR NAME" +"0","","YOUR NAME" +"0","if (FALSE) {""","YOUR NAME" +"0","7.3. Knight & Skagen (1988) collected the data shown in the table (and in data frame eagles) during a","YOUR NAME" +"0","field study on the foraging behavior of wintering Bald Eagles in Washington State, USA. The data","YOUR NAME" +"0","concern 160 attempts by one (pirating) Bald Eagle to steal a chum salmon from another (feeding) Bald","YOUR NAME" +"0","Eagle.","YOUR NAME" +"0","""}","YOUR NAME" +"0","library(MASS)","YOUR NAME" +"0","data <- eagles","YOUR NAME" +"0","str(data)","YOUR NAME" +"0","if (FALSE) {""","YOUR NAME" +"0","Report on factors that explain the success of the pirating attempt and give a prediction formula","YOUR NAME" +"0","for the probability of success.","YOUR NAME" +"0","""}","YOUR NAME" +"0","colnames(data) <- c(""Successes"", ""Attempts"", ""Size_Pirating"", ""Age_Pirating"", ""Size_Feeding"")","YOUR NAME" +"0","data$prop_successes <- (Successes/Attempts)","YOUR NAME" +"0","attach(data)","YOUR NAME" +"0","plot(Size_Pirating, prop_successes, main=""Proportion of Success vs Size of Pirating Eagle"")","YOUR NAME" +"0","plot(Size_Feeding, prop_successes, main = ""Proportion of Success vs Size of Feeding Eagle"")","YOUR NAME" +"0","plot(Age_Pirating, prop_successes, main = ""Proportion of Success vs Age of Pirating Eagle"")","YOUR NAME" +"0","propmod <- lm(prop_successes ~ ., data=data); summary(propmod)","YOUR NAME" +"0","is.factor(Age_Pirating)","YOUR NAME" +"0","is.factor(Size_Feeding)","YOUR NAME" +"0","is.factor(Size_Pirating)","YOUR NAME" +"0","logcode <- c(rep(1, 17), rep(0, 7), rep(1, 29), rep(1, 17), rep(0, 10), rep(1,20), rep(1, 1), rep(0, 11), rep(1, 15), rep(0, 1), rep(0, 28), rep(1, 1), rep(0, 3))","YOUR NAME" +"0","data2 <- data[rep(row.names(data), data$Attempts), 2","YOUR NAME" +"5]","","YOUR NAME" +"0","data2 <- data2[,c(2,3,4)]","YOUR NAME" +"0","df <- cbind(logcode, data2)","YOUR NAME" +"0","logmod <- glm(logcode ~ ., family=binomial(link='logit'), data=df)","YOUR NAME" +"0","summary(logmod)","YOUR NAME" +"0","plot(Size_Pirating, phat, main=""Proportion of Success vs Size of Pirating Eagle"")","YOUR NAME" +"0","","YOUR NAME" +"0","library(MASS)","YOUR NAME" +"0","data <- eagles","YOUR NAME" +"0","str(data)","YOUR NAME" +"0","if (FALSE) {""","YOUR NAME" +"0","Report on factors that explain the success of the pirating attempt and give a prediction formula","YOUR NAME" +"0","for the probability of success.","YOUR NAME" +"0","""}","YOUR NAME" +"0","colnames(data) <- c(""Successes"", ""Attempts"", ""Size_Pirating"", ""Age_Pirating"", ""Size_Feeding"")","YOUR NAME" +"0","data$phat <- (Successes/Attempts)","YOUR NAME" +"0","attach(data)","YOUR NAME" +"0","plot(Size_Pirating, phat, main=""Proportion of Success vs Size of Pirating Eagle"")","YOUR NAME" +"0","","YOUR NAME" +"0","library(MASS)","YOUR NAME" +"0","data <- eagles","YOUR NAME" +"0","str(data)","YOUR NAME" +"0","if (FALSE) {""","YOUR NAME" +"0","Report on factors that explain the success of the pirating attempt and give a prediction formula","YOUR NAME" +"0","for the probability of success.","YOUR NAME" +"0","""}","YOUR NAME" +"0","colnames(data) <- c(""Successes"", ""Attempts"", ""Size_Pirating"", ""Age_Pirating"", ""Size_Feeding"")","YOUR NAME" +"0","data$phat <- (Successes/Attempts)","YOUR NAME" +"0","attach(data)","YOUR NAME" +"0","","YOUR NAME" +"0","plot(Size_Pirating, phat, main=""Proportion of Success vs Size of Pirating Eagle"")","YOUR NAME" +"0","","YOUR NAME" +"0","library(MASS)","YOUR NAME" +"0","data <- eagles","YOUR NAME" +"0","str(data)","YOUR NAME" +"0","if (FALSE) {""","YOUR NAME" +"0","Report on factors that explain the success of the pirating attempt and give a prediction formula","YOUR NAME" +"0","for the probability of success.","YOUR NAME" +"0","""}","YOUR NAME" +"0","colnames(data) <- c(""Successes"", ""Attempts"", ""Size_Pirating"", ""Age_Pirating"", ""Size_Feeding"")","YOUR NAME" +"0","data$phat <- (Successes/Attempts)","YOUR NAME" +"0","attach(data)","YOUR NAME" +"0","","YOUR NAME" +"0","plot(Size_Pirating, phat, main=""Proportion of Success vs Size of Pirating Eagle"")","YOUR NAME" +"0","plot(Size_Feeding, phat, main = ""Proportion of Success vs Size of Feeding Eagle"")","YOUR NAME" +"0","","YOUR NAME" +"0","library(MASS)","YOUR NAME" +"0","data <- eagles","YOUR NAME" +"0","str(data)","YOUR NAME" +"0","if (FALSE) {""","YOUR NAME" +"0","Report on factors that explain the success of the pirating attempt and give a prediction formula","YOUR NAME" +"0","for the probability of success.","YOUR NAME" +"0","""}","YOUR NAME" +"0","colnames(data) <- c(""Successes"", ""Attempts"", ""Size_Pirating"", ""Age_Pirating"", ""Size_Feeding"")","YOUR NAME" +"0","data$phat <- (Successes/Attempts)","YOUR NAME" +"0","attach(data)","YOUR NAME" +"0","","YOUR NAME" +"0","plot(Size_Pirating, phat, main=""Proportion of Success vs Size of Pirating Eagle"")","YOUR NAME" +"0","plot(Size_Feeding, phat, main = ""Proportion of Success vs Size of Feeding Eagle"")","YOUR NAME" +"0","plot(Age_Pirating, phat, main = ""Proportion of Success vs Age of Pirating Eagle"")","YOUR NAME" +"0","","YOUR NAME" +"0","library(MASS)","YOUR NAME" +"0","data <- eagles","YOUR NAME" +"0","str(data)","YOUR NAME" +"0","if (FALSE) {""","YOUR NAME" +"0","Report on factors that explain the success of the pirating attempt and give a prediction formula","YOUR NAME" +"0","for the probability of success.","YOUR NAME" +"0","""}","YOUR NAME" +"0","colnames(data) <- c(""Successes"", ""Attempts"", ""Size_Pirating"", ""Age_Pirating"", ""Size_Feeding"")","YOUR NAME" +"0","data$phat <- (Successes/Attempts)","YOUR NAME" +"0","attach(data)","YOUR NAME" +"0","","YOUR NAME" +"0","plot(Size_Pirating, phat, main=""Proportion of Success vs Size of Pirating Eagle"")","YOUR NAME" +"0","plot(Size_Feeding, phat, main = ""Proportion of Success vs Size of Feeding Eagle"")","YOUR NAME" +"0","plot(Age_Pirating, phat, main = ""Proportion of Success vs Age of Pirating Eagle"")","YOUR NAME" +"0","propmod <- lm(prop_successes ~ ., data=data);","YOUR NAME" +"0","summary(propmod)","YOUR NAME" +"0","is.factor(Age_Pirating)","YOUR NAME" +"0","is.factor(Size_Feeding)","YOUR NAME" +"0","is.factor(Size_Pirating)","YOUR NAME" +"0","logcode <- c(rep(1, 17), rep(0, 7), rep(1, 29), rep(1, 17), rep(0, 10), rep(1,20), rep(1, 1), rep(0, 11), rep(1, 15), rep(0, 1), rep(0, 28), rep(1, 1), rep(0, 3))","YOUR NAME" +"0","data2 <- data[rep(row.names(data), data$Attempts), 2","YOUR NAME" +"5]","","YOUR NAME" +"0","data2 <- data2[,c(2,3,4)]","YOUR NAME" +"0","df <- cbind(logcode, data2)","YOUR NAME" +"0","logmod <- glm(logcode ~ ., family=binomial(link='logit'), data=df)","YOUR NAME" +"0","summary(logmod)","YOUR NAME" +"1462166753046","N = 35","YOUR NAME" +"1462166753087","n = 6","YOUR NAME" +"1462166753091","","YOUR NAME" +"1462166753094","sample(1","YOUR NAME" +"N, n)","","YOUR NAME" +"1462167831831","N = 35;","YOUR NAME" +"1462167831835","n = 6;","YOUR NAME" +"1462167831838","sample(1","YOUR NAME" +"N, n)","","YOUR NAME" +"1462167831841","","YOUR NAME" +"1462167831842","a = 2*2.5;","YOUR NAME" +"1462167831843","M = 2+5+8+4+8+6;","YOUR NAME" +"1462167831844","m_bar = M/a;","YOUR NAME" +"1462167831845","lamda_bar = m_bar/a;","YOUR NAME" +"1462167840358","N = 35;","YOUR NAME" +"1462167840360","n = 6;","YOUR NAME" +"1462167840364","sample(1","YOUR NAME" +"N, n)","","YOUR NAME" +"1462167840373","","YOUR NAME" +"1462167840376","a = 2*2.5;","YOUR NAME" +"1462167840377","M = 2+5+8+4+8+6;","YOUR NAME" +"1462167840378","m_bar = M/a;","YOUR NAME" +"1462167840380","lamda_bar = m_bar/a;","YOUR NAME" +"1462167840382","lamda_bar","YOUR NAME" +"1462168247538","","YOUR NAME" +"1462168247542","var_est = lamda_bar/(a*n);","YOUR NAME" +"1462168247546","var_est;","YOUR NAME" +"1462168247551","B = 2*sqrt(var_est);","YOUR NAME" +"1462168247552","B","YOUR NAME" +"1462168611146","","YOUR NAME" +"1462168611147","","YOUR NAME" +"1462168611152","N = 35;","YOUR NAME" +"1462168611157","n = 6;","YOUR NAME" +"1462168611162","sample(1","YOUR NAME" +"N, n)","","YOUR NAME" +"1462168611163","","YOUR NAME" +"1462168611164","a = 2*2.5;","YOUR NAME" +"1462168611166","","YOUR NAME" +"1462168611167","M2 = 2+5+8+4+8+6;","YOUR NAME" +"1462168611168","m_bar2 = M2/a;","YOUR NAME" +"1462168611170","lamda_bar2 = m_bar2/a;","YOUR NAME" +"1462168611171","lamda_bar2","YOUR NAME" +"1462168611172","","YOUR NAME" +"1462168611173","var_est2 = lamda_bar2/(a*n);","YOUR NAME" +"1462168611174","var_est2;","YOUR NAME" +"1462168611175","B2 = 2*sqrt(var_est2);","YOUR NAME" +"1462168611176","B2","YOUR NAME" +"1462170756582","","YOUR NAME" +"1462170756587","","YOUR NAME" +"1462170756592","N = 35;","YOUR NAME" +"1462170756598","n = 6;","YOUR NAME" +"1462170756600","sample(1","YOUR NAME" +"N, n)","","YOUR NAME" +"1462170756603","","YOUR NAME" +"1462170756605","a = 2*2.5;","YOUR NAME" +"1462170756608","","YOUR NAME" +"1462170756610","M2 = 3+0+4+11+13+10;","YOUR NAME" +"1462170756612","m_bar2 = M2/a;","YOUR NAME" +"1462170756615","lamda_bar2 = m_bar2/a;","YOUR NAME" +"1462170756618","lamda_bar2","YOUR NAME" +"1462170756620","","YOUR NAME" +"1462170756622","var_est2 = lamda_bar2/(a*n);","YOUR NAME" +"1462170756624","var_est2;","YOUR NAME" +"1462170756626","B2 = 2*sqrt(var_est2);","YOUR NAME" +"1462170756627","B2","YOUR NAME" +"1462170855254","","YOUR NAME" +"1462170855256","N = 35;","YOUR NAME" +"1462170855261","n = 6;","YOUR NAME" +"1462170855265","sample(1","YOUR NAME" +"N, n)","","YOUR NAME" +"1462170855270","","YOUR NAME" +"1462170855272","a = 2*2.5;","YOUR NAME" +"1462170855273","","YOUR NAME" +"1462170855274","M2 = 3+0+4+11+13+10;","YOUR NAME" +"1462170855275","m_bar2 = M2/a;","YOUR NAME" +"1462170855277","lamda_bar2 = m_bar2/a;","YOUR NAME" +"1462170855278","lamda_bar2","YOUR NAME" +"1462170855279","","YOUR NAME" +"1462170855281","var_est2 = lamda_bar2/(a*n);","YOUR NAME" +"1462170855283","var_est2;","YOUR NAME" +"1462170855284","B2 = 2*sqrt(var_est2);","YOUR NAME" +"1462170855286","B2","YOUR NAME" +"1462171259790","","YOUR NAME" +"1462171259797","N = 35;","YOUR NAME" +"1462171259805","n = 6;","YOUR NAME" +"1462171259813","sample(1","YOUR NAME" +"N, n)","","YOUR NAME" +"1462171259817","","YOUR NAME" +"1462171259819","a = 2*2.5;","YOUR NAME" +"1462171259822","","YOUR NAME" +"1462171259824","M3 = 4+0+18+8+0+1;","YOUR NAME" +"1462171259827","m_bar3 = M3/a;","YOUR NAME" +"1462171259829","lamda_bar3 = m_bar3/a;","YOUR NAME" +"1462171259832","lamda_bar3","YOUR NAME" +"1462171259835","","YOUR NAME" +"1462171259837","var_est3 = lamda_bar3/(a*n);","YOUR NAME" +"1462171259840","var_est3;","YOUR NAME" +"1462171259843","B3 = 2*sqrt(var_est3);","YOUR NAME" +"1462171259845","B3","YOUR NAME" +"1462171610536","","YOUR NAME" +"1462171610537","N = 35;","YOUR NAME" +"1462171610539","n = 6;","YOUR NAME" +"1462171610541","sample(1","YOUR NAME" +"N, n)","","YOUR NAME" +"1462171610542","","YOUR NAME" +"1462171610544","a = 2*2.5;","YOUR NAME" +"1462171610545","","YOUR NAME" +"1462171610546","M = 2+5+8+4+8+6;","YOUR NAME" +"1462171610549","m_bar = M/a;","YOUR NAME" +"1462171610550","lamda_bar = m_bar/a;","YOUR NAME" +"1462171610551","lamda_bar","YOUR NAME" +"1462171610553","","YOUR NAME" +"1462171610554","var_est = lamda_bar/(a*n);","YOUR NAME" +"1462171610556","var_est;","YOUR NAME" +"1462171610557","B = 2*sqrt(var_est);","YOUR NAME" +"1462171610559","B","YOUR NAME" +"1462171610560","","YOUR NAME" +"1462171610561","","YOUR NAME" +"1462171610563","N = 35;","YOUR NAME" +"1462171610564","n = 6;","YOUR NAME" +"1462171610565","sample(1","YOUR NAME" +"N, n)","","YOUR NAME" +"1462171610567","","YOUR NAME" +"1462171610569","a = 2*2.5;","YOUR NAME" +"1462171610572","","YOUR NAME" +"1462171610573","M2 = 3+0+4+11+13+10;","YOUR NAME" +"1462171610576","m_bar2 = M2/a;","YOUR NAME" +"1462171610578","lamda_bar2 = m_bar2/a;","YOUR NAME" +"1462171610580","lamda_bar2","YOUR NAME" +"1462171610582","","YOUR NAME" +"1462171610584","var_est2 = lamda_bar2/(a*n);","YOUR NAME" +"1462171610585","var_est2;","YOUR NAME" +"1462171610587","B2 = 2*sqrt(var_est2);","YOUR NAME" +"1462171610589","B2","YOUR NAME" +"1462171610590","","YOUR NAME" +"1462171610592","N = 35;","YOUR NAME" +"1462171610594","n = 6;","YOUR NAME" +"1462171610595","sample(1","YOUR NAME" +"N, n)","","YOUR NAME" +"1462171610597","","YOUR NAME" +"1462171610599","a = 2*2.5;","YOUR NAME" +"1462171610600","","YOUR NAME" +"1462171610601","M3 = 4+0+18+8+0+1;","YOUR NAME" +"1462171610603","m_bar3 = M3/a;","YOUR NAME" +"1462171610604","lamda_bar3 = m_bar3/a;","YOUR NAME" +"1462171610605","lamda_bar3","YOUR NAME" +"1462171610607","","YOUR NAME" +"1462171610608","var_est3 = lamda_bar3/(a*n);","YOUR NAME" +"1462171610609","var_est3;","YOUR NAME" +"1462171610611","B3 = 2*sqrt(var_est3);","YOUR NAME" +"1462171610613","B3","YOUR NAME" +"1462171728703","","YOUR NAME" +"1462171728708","N = 35;","YOUR NAME" +"1462171728713","n = 6;","YOUR NAME" +"1462171728717","sample(1","YOUR NAME" +"N, n)","","YOUR NAME" +"1462171728719","","YOUR NAME" +"1462171728720","a = 2*2.5;","YOUR NAME" +"1462171728722","","YOUR NAME" +"1462171728723","M3 = 14+0+18+8+0+1;","YOUR NAME" +"1462171728725","m_bar3 = M3/a;","YOUR NAME" +"1462171728727","lamda_bar3 = m_bar3/a;","YOUR NAME" +"1462171728729","lamda_bar3","YOUR NAME" +"1462171728731","","YOUR NAME" +"1462171728732","var_est3 = lamda_bar3/(a*n);","YOUR NAME" +"1462171728734","var_est3;","YOUR NAME" +"1462171728736","B3 = 2*sqrt(var_est3);","YOUR NAME" +"1462171728737","B3","YOUR NAME" +"1462171739255","","YOUR NAME" +"1462171739257","N = 35;","YOUR NAME" +"1462171739261","n = 6;","YOUR NAME" +"1462171739266","sample(1","YOUR NAME" +"N, n)","","YOUR NAME" +"1462171739271","","YOUR NAME" +"1462171739272","a = 2*2.5;","YOUR NAME" +"1462171739273","","YOUR NAME" +"1462171739274","M3 = 15+0+18+8+0+1;","YOUR NAME" +"1462171739276","m_bar3 = M3/a;","YOUR NAME" +"1462171739277","lamda_bar3 = m_bar3/a;","YOUR NAME" +"1462171739279","lamda_bar3","YOUR NAME" +"1462171739280","","YOUR NAME" +"1462171739281","var_est3 = lamda_bar3/(a*n);","YOUR NAME" +"1462171739283","var_est3;","YOUR NAME" +"1462171739284","B3 = 2*sqrt(var_est3);","YOUR NAME" +"1462171739286","B3","YOUR NAME" +"1462171828130","","YOUR NAME" +"1462171828131","N = 35;","YOUR NAME" +"1462171828136","n = 6;","YOUR NAME" +"1462171828140","sample(1","YOUR NAME" +"N, n)","","YOUR NAME" +"1462171828145","","YOUR NAME" +"1462171828146","a = 2*2.5;","YOUR NAME" +"1462171828147","","YOUR NAME" +"1462171828148","M = 2+5+8+4+8+6;","YOUR NAME" +"1462171828150","m_bar = M/a;","YOUR NAME" +"1462171828151","lamda_bar = m_bar/a;","YOUR NAME" +"1462171828152","lamda_bar","YOUR NAME" +"1462171828153","","YOUR NAME" +"1462171828154","var_est = lamda_bar/(a*n);","YOUR NAME" +"1462171828156","var_est;","YOUR NAME" +"1462171828157","B = 2*sqrt(var_est);","YOUR NAME" +"1462171828158","B","YOUR NAME" +"1462171828160","","YOUR NAME" +"1462171828161","","YOUR NAME" +"1462171828162","N = 35;","YOUR NAME" +"1462171828163","n = 6;","YOUR NAME" +"1462171828165","sample(1","YOUR NAME" +"N, n)","","YOUR NAME" +"1462171828167","","YOUR NAME" +"1462171828168","a = 2*2.5;","YOUR NAME" +"1462171828169","","YOUR NAME" +"1462171828170","M2 = 3+0+4+11+13+10;","YOUR NAME" +"1462171828171","m_bar2 = M2/a;","YOUR NAME" +"1462171828173","lamda_bar2 = m_bar2/a;","YOUR NAME" +"1462171828174","lamda_bar2","YOUR NAME" +"1462171828176","","YOUR NAME" +"1462171828177","var_est2 = lamda_bar2/(a*n);","YOUR NAME" +"1462171828179","var_est2;","YOUR NAME" +"1462171828181","B2 = 2*sqrt(var_est2);","YOUR NAME" +"1462171828183","B2","YOUR NAME" +"1462171828184","","YOUR NAME" +"1462171828186","N = 35;","YOUR NAME" +"1462171828187","n = 6;","YOUR NAME" +"1462171828189","sample(1","YOUR NAME" +"N, n)","","YOUR NAME" +"1462171828190","","YOUR NAME" +"1462171828192","a = 2*2.5;","YOUR NAME" +"1462171828193","","YOUR NAME" +"1462171828194","M3 = 15+0+18+8+0+1;","YOUR NAME" +"1462171828195","m_bar3 = M3/a;","YOUR NAME" +"1462171828196","lamda_bar3 = m_bar3/a;","YOUR NAME" +"1462171828197","lamda_bar3","YOUR NAME" +"1462171828199","","YOUR NAME" +"1462171828200","var_est3 = lamda_bar3/(a*n);","YOUR NAME" +"1462171828201","var_est3;","YOUR NAME" +"1462171828202","B3 = 2*sqrt(var_est3);","YOUR NAME" +"1462171828204","B3","YOUR NAME" +"1462677021279","setwd(""C","YOUR NAME" +"/Users/Nino Zhang/Documents/Nino Zhang/study at Rutgers/spring 2016/data final project"")","","YOUR NAME" +"1462677021298","animals <- read.table(""animals.txt"", sep="","", header = TRUE)","YOUR NAME" +"1462677021306","head(animals)","YOUR NAME" +"1462677138864","setwd(""C","YOUR NAME" +"/Users/Nino Zhang/Documents/Nino Zhang/study at Rutgers/spring 2016/data final project"")","","YOUR NAME" +"1462677138866","Poverty <- read.table(""Poverty.txt"", sep="","", header = TRUE)","YOUR NAME" +"1462677138943","head(Poverty)","YOUR NAME" +"1462677364077","setwd(""C","YOUR NAME" +"/Nino Zhang/study at Rutgers/spring 2016/data hw2"")","","YOUR NAME" +"1462677364079","animals <- read.table(""animals.txt"", sep="","", header = TRUE)","YOUR NAME" +"1462677364081","head(animals)","YOUR NAME" +"1462677382805","setwd(""C","YOUR NAME" +"/Users/Nino Zhang/Documents/Nino Zhang/study at Rutgers/spring 2016/data final project"")","","YOUR NAME" +"1462677382809","Poverty <- read.table(""Poverty.txt"", sep="" "", header = TRUE)","YOUR NAME" +"1462677382857","head(Poverty)","YOUR NAME" +"1462677420170","setwd(""C","YOUR NAME" +"/Users/Nino Zhang/Documents/Nino Zhang/study at Rutgers/spring 2016/data final project"")","","YOUR NAME" +"1462677420174","Poverty <- read.table(""Poverty.txt"", sep=""\t"", header = TRUE)","YOUR NAME" +"1462677420179","head(Poverty)","YOUR NAME" +"1462677556300","setwd(""C","YOUR NAME" +"/Users/Nino Zhang/Documents/Nino Zhang/study at Rutgers/spring 2016/data final project"")","","YOUR NAME" +"1462677556302","Poverty <- read.table(""Poverty.txt"", sep=""\t"", header = TRUE)","YOUR NAME" +"1462677556308","head(Poverty)","YOUR NAME" +"1462677921365","xyplot(NationalGDP ~ BirthRate | NationalGDP, BirthRate, groups = BirthRate$NationalGDP, pch= 20)","YOUR NAME" +"1462677960614","ggplot(NationalGDP ~ BirthRate | NationalGDP, BirthRate, groups = BirthRate$NationalGDP, pch= 20)","YOUR NAME" +"1462677999990","plot(NationalGDP ~ BirthRate | NationalGDP, BirthRate, groups = BirthRate$NationalGDP, pch= 20)","YOUR NAME" +"1462678168863","library(ggplot2)","YOUR NAME" +"1462678176054","library(ggplot)","YOUR NAME" +"1462678183331","library(xyplot)","YOUR NAME" +"1462678279899","install.packages(""ggplot2"")","YOUR NAME" +"1462678341708","library(ggplot2)","YOUR NAME" +"1462678396802","xyplot(NationalGDP ~ BirthRate | NationalGDP, BirthRate, groups = BirthRate$NationalGDP, pch= 20)","YOUR NAME" +"1462678727191","qplot(data=myData,x=BM,y=var1,log=”xy”,color=Tribe,facets =","YOUR NAME" +"1462678801409","qplot(data=Poverty,x=NationalGDP,y=BirthRate,log=”xy”,color=Country,facets = ~Country)","YOUR NAME" +"1462678929473","qplot(data=Poverty,x=NationalGDP,y=BirthRate,log=”xy”,color=Country)","YOUR NAME" +"1462678954911","ggplot(data=Poverty,x=NationalGDP,y=BirthRate,log=”xy”,color=Country)","YOUR NAME" +"1462678979256","library(ggplot2)","YOUR NAME" +"1462679052754","qplot(data=Poverty,x=Country,main=”Histogram of BodyMass”)","YOUR NAME" +"1462679131036","plot(BirthRate, NationalGDP, main=""Scatterplot Example"",","YOUR NAME" +"1462679131039","xlab=""Car Weight "", ylab=""Miles Per Gallon "", pch=19)","YOUR NAME" +"1462679183192","attach(Poverty)","YOUR NAME" +"1462679183216","plot(BirthRate, NationalGDP, main=""Scatterplot Example"",","YOUR NAME" +"1462679183219","xlab=""Car Weight "", ylab=""Miles Per Gallon "", pch=19)","YOUR NAME" +"1462679195911","setwd(""C","YOUR NAME" +"/Users/Nino Zhang/Documents/Nino Zhang/study at Rutgers/spring 2016/data final project"")","","YOUR NAME" +"1462679195912","Poverty <- read.table(""Poverty.txt"", sep=""\t"", header = TRUE)","YOUR NAME" +"1462679195918","head(Poverty)","YOUR NAME" +"1462679195925","attach(Poverty)","YOUR NAME" +"1462679195950","plot(BirthRate, NationalGDP, main=""Scatterplot Example"",","YOUR NAME" +"1462679195952","xlab=""Car Weight "", ylab=""Miles Per Gallon "", pch=19)","YOUR NAME" +"1462679207066","setwd(""C","YOUR NAME" +"/Users/Nino Zhang/Documents/Nino Zhang/study at Rutgers/spring 2016/data final project"")","","YOUR NAME" +"1462679207070","Poverty <- read.table(""Poverty.txt"", sep=""\t"", header = TRUE)","YOUR NAME" +"1462679207075","head(Poverty)","YOUR NAME" +"1462679207082","attach(Poverty)","YOUR NAME" +"1462679207106","plot(BirthRate, NationalGDP, main=""Scatterplot Example"",","YOUR NAME" +"1462679207107","xlab=""Car Weight "", ylab=""Miles Per Gallon "", pch=5)","YOUR NAME" +"1462679221629","setwd(""C","YOUR NAME" +"/Users/Nino Zhang/Documents/Nino Zhang/study at Rutgers/spring 2016/data final project"")","","YOUR NAME" +"1462679221632","Poverty <- read.table(""Poverty.txt"", sep=""\t"", header = TRUE)","YOUR NAME" +"1462679221639","head(Poverty)","YOUR NAME" +"1462679221646","attach(Poverty)","YOUR NAME" +"1462679221670","plot(BirthRate, NationalGDP, main=""Scatterplot Example"",","YOUR NAME" +"1462679221671","xlab=""Car Weight "", ylab=""Miles Per Gallon "", pch=1)","YOUR NAME" +"1462679235257","setwd(""C","YOUR NAME" +"/Users/Nino Zhang/Documents/Nino Zhang/study at Rutgers/spring 2016/data final project"")","","YOUR NAME" +"1462679235258","Poverty <- read.table(""Poverty.txt"", sep=""\t"", header = TRUE)","YOUR NAME" +"1462679235263","head(Poverty)","YOUR NAME" +"1462679235271","attach(Poverty)","YOUR NAME" +"1462679235300","plot(BirthRate, NationalGDP, main=""Scatterplot Example"",","YOUR NAME" +"1462679235301","xlab=""Car Weight "", ylab=""Miles Per Gallon "")","YOUR NAME" +"1462679387567","setwd(""C","YOUR NAME" +"/Users/Nino Zhang/Documents/Nino Zhang/study at Rutgers/spring 2016/data final project"")","","YOUR NAME" +"1462679387568","Poverty <- read.table(""Poverty.txt"", sep=""\t"", header = TRUE)","YOUR NAME" +"1462679387571","head(Poverty)","YOUR NAME" +"1462679387576","attach(Poverty)","YOUR NAME" +"1462679387605","plot(BirthRate, NationalGDP, main=""Scatterplot Example"",","YOUR NAME" +"1462679387606","xlab=""Car Weight "", ylab=""Miles Per Gallon "")","YOUR NAME" +"1462679501130","setwd(""C","YOUR NAME" +"/Users/Nino Zhang/Documents/Nino Zhang/study at Rutgers/spring 2016/data final project"")","","YOUR NAME" +"1462679501132","Poverty <- read.table(""Poverty.txt"", sep=""\t"", header = TRUE)","YOUR NAME" +"1462679501136","head(Poverty)","YOUR NAME" +"1462679501184","attach(Poverty)","YOUR NAME" +"1462679501304","plot(BirthRate, InfantMortality, main=""Birth Rate vs Infant Mortality"",","YOUR NAME" +"1462679501305","xlab=""BirthRate "", ylab=""InfantMortality "")","YOUR NAME" +"1462679534379","setwd(""C","YOUR NAME" +"/Users/Nino Zhang/Documents/Nino Zhang/study at Rutgers/spring 2016/data final project"")","","YOUR NAME" +"1462679534383","Poverty <- read.table(""Poverty.txt"", sep=""\t"", header = TRUE)","YOUR NAME" +"1462679534388","head(Poverty)","YOUR NAME" +"1462679534395","attach(Poverty)","YOUR NAME" +"1462679534422","plot(BirthRate, InfantMortality,","YOUR NAME" +"1462679534423","xlab=""BirthRate "", ylab=""InfantMortality "")","YOUR NAME" +"1462679615318","par(mar = rep(2, 4))","YOUR NAME" +"1462679615322","attach(Poverty)","YOUR NAME" +"1462679615355","plot(BirthRate, InfantMortality,","YOUR NAME" +"1462679615359","xlab=""BirthRate "", ylab=""InfantMortality "")","YOUR NAME" +"1462679681441","setwd(""C","YOUR NAME" +"/Users/Nino Zhang/Documents/Nino Zhang/study at Rutgers/spring 2016/data final project"")","","YOUR NAME" +"1462679681443","Poverty <- read.table(""Poverty.txt"", sep=""\t"", header = TRUE)","YOUR NAME" +"1462679681446","head(Poverty)","YOUR NAME" +"1462679681451","par(mar = rep(2, 4))","YOUR NAME" +"1462679681452","attach(Poverty)","YOUR NAME" +"1462679681485","plot(BirthRate, InfantMortality,","YOUR NAME" +"1462679681487","xlab=""BirthRate "", ylab=""InfantMortality "")","YOUR NAME" +"1462679746693","setwd(""C","YOUR NAME" +"/Users/Nino Zhang/Documents/Nino Zhang/study at Rutgers/spring 2016/data final project"")","","YOUR NAME" +"1462679746697","Poverty <- read.table(""Poverty.txt"", sep=""\t"", header = TRUE)","YOUR NAME" +"1462679746702","head(Poverty)","YOUR NAME" +"1462679746726","par(mar = rep(2, 4))","YOUR NAME" +"1462679746728","attach(Poverty)","YOUR NAME" +"1462679746766","plot(BirthRate, InfantMortality,","YOUR NAME" +"1462679746767","xlab=""BirthRate "", ylab=""InfantMortality "", main = 'BirthRate vs InfantMortality')","YOUR NAME" +"1462679784475","setwd(""C","YOUR NAME" +"/Users/Nino Zhang/Documents/Nino Zhang/study at Rutgers/spring 2016/data final project"")","","YOUR NAME" +"1462679784479","Poverty <- read.table(""Poverty.txt"", sep=""\t"", header = TRUE)","YOUR NAME" +"1462679784484","head(Poverty)","YOUR NAME" +"1462679784490","par(mar = rep(2, 4))","YOUR NAME" +"1462679784491","attach(Poverty)","YOUR NAME" +"1462679784524","plot(BirthRate, NationalGDP,","YOUR NAME" +"1462679784526","xlab=""BirthRate "", ylab=""NationalGDP "", main = 'BirthRate vs InfantMortality')","YOUR NAME" +"1462679886879","setwd(""C","YOUR NAME" +"/Users/Nino Zhang/Documents/Nino Zhang/study at Rutgers/spring 2016/data final project"")","","YOUR NAME" +"1462679886880","Poverty <- read.table(""Poverty.txt"", sep=""\t"", header = TRUE)","YOUR NAME" +"1462679886886","head(Poverty)","YOUR NAME" +"1462679886892","par(mar = rep(2, 4))","YOUR NAME" +"1462679886896","","YOUR NAME" +"1462679886897","attach(Poverty)","YOUR NAME" +"1462679886929","plot(BirthRate, NationalGDP,","YOUR NAME" +"1462679886930","xlab=""BirthRate "", ylab=""NationalGDP "", main = 'BirthRate vs InfantMortality')","YOUR NAME" +"1462679943817","setwd(""C","YOUR NAME" +"/Users/Nino Zhang/Documents/Nino Zhang/study at Rutgers/spring 2016/data final project"")","","YOUR NAME" +"1462679943818","Poverty <- read.table(""Poverty.txt"", sep=""\t"", header = TRUE)","YOUR NAME" +"1462679943823","head(Poverty)","YOUR NAME" +"1462679943830","par(mar = rep(2, 4))","YOUR NAME" +"1462679943833","","YOUR NAME" +"1462679943834","attach(Poverty)","YOUR NAME" +"1462679943865","plot(BirthRate, NationalGDP,","YOUR NAME" +"1462679943866","xlab=""BirthRate "", ylab=""NationalGDP "", main = 'BirthRate vs InfantMortality')","YOUR NAME" +"1462679943883","bline(lm(BirthRate ~ NationalGDP))","YOUR NAME" +"1462679955504","setwd(""C","YOUR NAME" +"/Users/Nino Zhang/Documents/Nino Zhang/study at Rutgers/spring 2016/data final project"")","","YOUR NAME" +"1462679955506","Poverty <- read.table(""Poverty.txt"", sep=""\t"", header = TRUE)","YOUR NAME" +"1462679955510","head(Poverty)","YOUR NAME" +"1462679955517","par(mar = rep(2, 4))","YOUR NAME" +"1462679955521","","YOUR NAME" +"1462679955521","attach(Poverty)","YOUR NAME" +"1462679955553","plot(BirthRate, NationalGDP,","YOUR NAME" +"1462679955554","xlab=""BirthRate "", ylab=""NationalGDP "", main = 'BirthRate vs InfantMortality')","YOUR NAME" +"1462679955575","abline(lm(BirthRate ~ NationalGDP))","YOUR NAME" +"1462680049881","fit <- lm(BirthRate ~ NationalGDP, data=Poverty)","YOUR NAME" +"1462680049886","summary(fit)","YOUR NAME" +"1462680270754","setwd(""C","YOUR NAME" +"/Users/Nino Zhang/Documents/Nino Zhang/study at Rutgers/spring 2016/data final project"")","","YOUR NAME" +"1462680270758","Poverty <- read.table(""Poverty.txt"", sep=""\t"", header = TRUE)","YOUR NAME" +"1462680270763","head(Poverty)","YOUR NAME" +"1462680270770","par(mar = rep(2, 4))","YOUR NAME" +"1462680270772","","YOUR NAME" +"1462680270772","attach(Poverty)","YOUR NAME" +"1462680270806","plot(BirthRate, NationalGDP,","YOUR NAME" +"1462680270807","xlab=""BirthRate "", ylab=""NationalGDP "", main = 'BirthRate vs NationalGDP')","YOUR NAME" +"1462680270824","abline(lm(BirthRate ~ NationalGDP))","YOUR NAME" +"1462680270828","fit <- lm(BirthRate ~ NationalGDP, data=Poverty)","YOUR NAME" +"1462680270832","summary(fit)","YOUR NAME" +"1462680270841","","YOUR NAME" +"1462680270842","","YOUR NAME" +"1462682118800","plot(InfantMortality, NationalGDP,","YOUR NAME" +"1462682118804","xlab=""InfantMortality "", ylab=""NationalGDP "", main = 'InfantMortality vs NationalGDP')","YOUR NAME" +"1462682118825","abline(lm(InfantMortality ~ NationalGDP))","YOUR NAME" +"1462682118832","fit <- lm(InfantMortality ~ NationalGDP, data=Poverty)","YOUR NAME" +"1462682118836","summary(fit)","YOUR NAME" +"1462682146990","plot(InfantMortality, NationalGDP,","YOUR NAME" +"1462682146994","xlab=""InfantMortality "", ylab=""NationalGDP "", main = 'InfantMortality vs NationalGDP')","YOUR NAME" +"1462682147012","abline(lm(InfantMortality ~ NationalGDP))","YOUR NAME" +"1462682147017","fit <- lm(InfantMortality ~ NationalGDP, data=Poverty)","YOUR NAME" +"1462682147020","summary(fit)","YOUR NAME" +"1462842878649","t.test(Poverty.LifeExpectationMale, Poverty.LifeExpectationFemale)","YOUR NAME" +"1462842943864","t.test(Poverty.LifeExpectationMale, Poverty.LifeExpectationFemale)","YOUR NAME" +"1462842988898","t.test(LifeExpectationMale, LifeExpectationFemale)","YOUR NAME" +"1462843353832","boxplot(LifeExpectationMale~LifeExpectationFemale,data=Poverty, main=""life expectations of males and females"",","YOUR NAME" +"1462843353834",")","YOUR NAME" +"1462843389208","boxplot(LifeExpectationMale~LifeExpectationFemale,data=Poverty, main=""life expectations of males and females""","YOUR NAME" +"1462843389209",")","YOUR NAME" +"1462843803778","boxplot(Poverty, las = 2, names = c(“LifeExpectationMale″,“LifeExpectationFemale″))","YOUR NAME" +"1462844010718","x=LifeExpectationMale","YOUR NAME" +"1462844010754","y=LifeExpectationFemale","YOUR NAME" +"1462844010756","boxplot(x,y)","YOUR NAME" +"1462844083269","x=LifeExpectationMale","YOUR NAME" +"1462844083271","y=LifeExpectationFemale","YOUR NAME" +"1462844083272","boxplot(x,y,names = c(""LifeExpectationMale"",""LifeExpectationFemale""))","YOUR NAME" +"1462844104925","boxplot(LifeExpectationMale,LifeExpectationFemale,names = c(""LifeExpectationMale"",""LifeExpectationFemale""))","YOUR NAME" +"1462844113114","boxplot(LifeExpectationMale,LifeExpectationFemale,names = c(""LifeExpectationMale"",""LifeExpectationFemale""))","YOUR NAME" +"1462845301770","N1 = NationalGDP if (RegionCode =1)","YOUR NAME" +"1462845315459","N1 = NationalGDP,RegionCode =1","YOUR NAME" +"1462845625551","N1 = (NationalGDP,RegionCode == 1)","YOUR NAME" +"1462845634084","N1 = (NationalGDP, RegionCode == 1)","YOUR NAME" +"1462845641930","N1 = (NationalGDP RegionCode == 1)","YOUR NAME" +"1462845729239","N1 = NationalGDP [RegionCode == 1]","YOUR NAME" +"1462845740084","","YOUR NAME" +"1462845740088","N1 = NationalGDP [RegionCode == 1]","YOUR NAME" +"1462845740091","N1","YOUR NAME" +"1462845794241","N1 = NationalGDP [RegionCode == 1]","YOUR NAME" +"1462845794245","N1","YOUR NAME" +"1462845794248","N2 = NationalGDP [RegionCode == 2]","YOUR NAME" +"1462845794252","N2","YOUR NAME" +"1462845794253","N3 = NationalGDP [RegionCode == 3]","YOUR NAME" +"1462845794254","N3","YOUR NAME" +"1462845931489","tapply(N1, N2, N3, mean)","YOUR NAME" +"1462846115740","","YOUR NAME" +"1462846115741","> x.dt[, list(N1_mean = mean(N1)","YOUR NAME" +"1462846115744","+ , N2_mean = mean(N2)","YOUR NAME" +"1462846115748","+ , N3_mean = mean(N3)","YOUR NAME" +"1462846115751","+ ), by = RegionCode]","YOUR NAME" +"1462846123552","x.dt[, list(N1_mean = mean(N1)","YOUR NAME" +"1462846123553","+ , N2_mean = mean(N2)","YOUR NAME" +"1462846123556","+ , N3_mean = mean(N3)","YOUR NAME" +"1462846123560","+ ), by = RegionCode]","YOUR NAME" +"1462846149865","N1_mean = mean(N1)","YOUR NAME" +"1462846158489","N1_mean = mean(N1)","YOUR NAME" +"1462846158490","N1_mean","YOUR NAME" +"1462846196521","N1_mean = mean(N1), N2_mean = mean(N2), N3_mean = mean(N3)","YOUR NAME" +"1462846196524","N1_mean, N2_mean, N3_mean","YOUR NAME" +"1462846207240","N1_mean = mean(N1), N2_mean = mean(N2), N3_mean = mean(N3)","YOUR NAME" +"1462846207244","N1_mean N2_mean N3_mean","YOUR NAME" +"1462846218270","N1_mean = mean(N1), N2_mean = mean(N2), N3_mean = mean(N3)","YOUR NAME" +"1462846218271","N1_mean","YOUR NAME" +"1462846218273","N2_mean","YOUR NAME" +"1462846218274","N3_mean","YOUR NAME" +"1462846233208","N1_mean = mean(N1), N2_mean = mean(N2), N3_mean = mean(N3)","YOUR NAME" +"1462846233239","N1_mean ;","YOUR NAME" +"1462846233243","N2_mean ;","YOUR NAME" +"1462846233246","N3_mean","YOUR NAME" +"1462846257865","N1_mean = mean(N1); N2_mean = mean(N2); N3_mean = mean(N3)","YOUR NAME" +"1462846257867","N1_mean ;","YOUR NAME" +"1462846257869","N2_mean ;","YOUR NAME" +"1462846257870","N3_mean","YOUR NAME" +"1462846267804","N3","YOUR NAME" +"1462846267808","N1_mean = mean(N1); N2_mean = mean(N2); N3_mean = mean(N3)","YOUR NAME" +"1462846267812","N1_mean ;N2_mean ;N3_mean","YOUR NAME" +"1462846637768","ajuste <- lm(NationalGDP ~ N1 + N2 + N3)","YOUR NAME" +"1462846637837","summary(ajuste)","YOUR NAME" +"1462846637841","anova(ajuste)","YOUR NAME" +"1462846726239","fit <- aov(y ~ N1+N2+N3, data=poverty)","YOUR NAME" +"1462846734899","fit <- aov(y ~ N1+N2+N3, data=Poverty)","YOUR NAME" +"1462847637256","","YOUR NAME" +"1462847637260","Data <- data.frame(","YOUR NAME" +"1462847637263","Y=c(N1, N2, N3),","YOUR NAME" +"1462847637266","Site =factor(rep(c(""site1"", ""site2"", ""site3"", ""site4""), sizes=c(length(N1), length(N2), length(N3)))","YOUR NAME" +"1462847637267",")","YOUR NAME" +"1462847670690","Data <- data.frame(","YOUR NAME" +"1462847670695","Y=c(N1, N2, N3),","YOUR NAME" +"1462847670698","Site =factor(rep(c(""site1"", ""site2"", ""site3"", ""site4""), sizes=c(length(N1), length(N2), length(N3)))","YOUR NAME" +"1462847670701",")","YOUR NAME" +"1462847670702","fm1 <- aov(Y~sized, data=Data)","YOUR NAME" +"1462847670704","anova(fm1)","YOUR NAME" +"1462847696131","Data <- data.Poverty(","YOUR NAME" +"1462847696132","Y=c(N1, N2, N3),","YOUR NAME" +"1462847696135","Site =factor(rep(c(""site1"", ""site2"", ""site3"", ""site4""), sizes=c(length(N1), length(N2), length(N3)))","YOUR NAME" +"1462847696138",")","YOUR NAME" +"1462847696141","fm1 <- aov(Y~sized, data=Data)","YOUR NAME" +"1462847696142","anova(fm1)","YOUR NAME" +"1462847701662","Data <- data.Poverty(","YOUR NAME" +"1462847701663","Y=c(N1, N2, N3),","YOUR NAME" +"1462847701664","Site =factor(rep(c(""site1"", ""site2"", ""site3"", ""site4""), sizes=c(length(N1), length(N2), length(N3)))","YOUR NAME" +"1462847701665",")","YOUR NAME" +"1462847814974","Y=c(N1, N2, N3)","YOUR NAME" +"1462847837162","Data <- data.Poverty(","YOUR NAME" +"1462847837166","Y=c(N1, N2, N3),","YOUR NAME" +"1462847837170","Site =factor(rep(c(""site1"", ""site2"", ""site3"", ""site4""), sizes=c(length(N1), length(N2), length(N3)))","YOUR NAME" +"1462847837173",")","YOUR NAME" +"1462847837174","fm1 <- aov(Y~Site, data=Data)","YOUR NAME" +"1462847837175","anova(fm1)","YOUR NAME" +"1462847859223","Data <- data.Poverty(","YOUR NAME" +"1462847859224","Y=c(N1, N2, N3),","YOUR NAME" +"1462847859228","Site =factor(rep(c(""site1"", ""site2"", ""site3"", ""site4""), sizes=c(length(N1), length(N2), length(N3)))","YOUR NAME" +"1462847859231",");","YOUR NAME" +"1462847859234","fm1 <- aov(Y~Site, data=Data)","YOUR NAME" +"1462847859236","anova(fm1)","YOUR NAME" +"1462847904069","Data <- data.frame(","YOUR NAME" +"1462847904070","Y=c(N1, N2, N3),","YOUR NAME" +"1462847904071","Site =factor(rep(c(""site1"", ""site2"", ""site3"", ""site4""), sizes=c(length(N1), length(N2), length(N3)))","YOUR NAME" +"1462847904072",")","YOUR NAME" +"1462847910723","Data <- data.frame(","YOUR NAME" +"1462847910724","Y=c(N1, N2, N3),","YOUR NAME" +"1462847910725","Site =factor(rep(c(""site1"", ""site2"", ""site3"", ""site4""), sizes=c(length(N1), length(N2), length(N3)))","YOUR NAME" +"1462847910726",")","YOUR NAME" +"1462847910727","fm1 <- aov(Y~Site, data=Data)","YOUR NAME" +"1462847910729","anova(fm1)","YOUR NAME" +"1462848339380","Data <- data.frame(","YOUR NAME" +"1462848339381","Y=c(N1, N2, N3),","YOUR NAME" +"1462848339385","Site =factor(rep(c(""N1"", ""N2"", ""N3""), sizes=c(length(N1), length(N2), length(N3)))","YOUR NAME" +"1462848339388",")","YOUR NAME" +"1462848345193","Data <- data.frame(","YOUR NAME" +"1462848345196","Y=c(N1, N2, N3),","YOUR NAME" +"1462848345200","Site =factor(rep(c(""N1"", ""N2"", ""N3""), sizes=c(length(N1), length(N2), length(N3)))","YOUR NAME" +"1462848345203",")","YOUR NAME" +"1462848345204","fm1 <- aov(Y~Site, data=Data)","YOUR NAME" +"1462848345206","anova(fm1)","YOUR NAME" +"1462848355006","Data <- data.frame(","YOUR NAME" +"1462848355007","Y=c(N1, N2, N3),","YOUR NAME" +"1462848355008","Site =factor(rep(c(""N1"", ""N2"", ""N3""), sizes=c(length(N1), length(N2), length(N3)))","YOUR NAME" +"1462848355008",")","YOUR NAME" +"1462848363787","Data <- data.frame(","YOUR NAME" +"1462848363788","Y=c(N1, N2, N3),","YOUR NAME" +"1462848363792","Site =factor(rep(c(""N1"", ""N2"", ""N3""), sizes=c(length(N1), length(N2), length(N3)))","YOUR NAME" +"1462848363795",")","YOUR NAME" +"1462848363799","Date","YOUR NAME" +"1462848453381","Data <- data.frame(","YOUR NAME" +"1462848453385","Y=c(N1, N2, N3),","YOUR NAME" +"1462848453388","Site =factor(rep(c(""N1"", ""N2"", ""N3""), times=c(length(N1), length(N2), length(N3))))","YOUR NAME" +"1462848453392",")","YOUR NAME" +"1462848469477","Data <- data.frame(","YOUR NAME" +"1462848469478","Y=c(N1, N2, N3),","YOUR NAME" +"1462848469481","Site =factor(rep(c(""N1"", ""N2"", ""N3""), times=c(length(N1), length(N2), length(N3))))","YOUR NAME" +"1462848469484",")","YOUR NAME" +"1462848469488","fm1 <- aov(Y~Site, data=Data)","YOUR NAME" +"1462848469492","anova(fm1)","YOUR NAME" +"1462849089914","Data <- data.frame(","YOUR NAME" +"1462849089915","Y=c(N1, N2, N3),","YOUR NAME" +"1462849089919","Nations =factor(rep(c(""N1"", ""N2"", ""N3""), times=c(length(N1), length(N2), length(N3))))","YOUR NAME" +"1462849089922",")","YOUR NAME" +"1462849089927","fm1 <- aov(Y~Nations, data=Data)","YOUR NAME" +"1462849089933","anova(fm1)","YOUR NAME" +"1462856750316","setwd(""C","YOUR NAME" +"/Users/Nino Zhang/Documents/Nino Zhang/study at Rutgers/spring 2016/data final project"")","","YOUR NAME" +"1462856750355","GDP <- read.table(""GDP.txt"", sep=""\t"", header = TRUE)","YOUR NAME" +"1462856750363","head(GDP)","YOUR NAME" +"1462856750367","par(mar = rep(2, 4))","YOUR NAME" +"1462857274849","attach(GDP)","YOUR NAME" +"1462857274873","plot(GDP, Trade,","YOUR NAME" +"1462857274877","xlab=""GDP "", ylab=""Trade "", main = 'GDP vs Trade')","YOUR NAME" +"1462857274883","abline(lm(GDP ~ Trade))","YOUR NAME" +"1462857274921","fit <- lm(GDP ~ Trade, data=GDP)","YOUR NAME" +"1462857274925","summary(fit)","YOUR NAME" +"1462857292879","attach(GDP)","YOUR NAME" +"1462857292902","plot(GDP, Trade,","YOUR NAME" +"1462857292903","xlab=""GDP"", ylab=""Trade"", main = 'GDP vs Trade')","YOUR NAME" +"1462857292906","abline(lm(GDP ~ Trade))","YOUR NAME" +"1462857292908","fit <- lm(GDP ~ Trade, data=GDP)","YOUR NAME" +"1462857292911","summary(fit)","YOUR NAME" +"1462857307975","attach(GDP)","YOUR NAME" +"1462857308000","plot(GDP, Trade,","YOUR NAME" +"1462857308002","main = 'GDP vs Trade')","YOUR NAME" +"1462857308056","abline(lm(GDP ~ Trade))","YOUR NAME" +"1462857308061","fit <- lm(GDP ~ Trade, data=GDP)","YOUR NAME" +"1462857308064","summary(fit)","YOUR NAME" +"1462859356881","setwd(""C","YOUR NAME" +"/Users/Nino Zhang/Documents/Nino Zhang/study at Rutgers/spring 2016/data final project"")","","YOUR NAME" +"1462859356883","Poverty <- read.table(""Poverty.txt"", sep=""\t"", header = TRUE)","YOUR NAME" +"1462859356928","head(Poverty)","YOUR NAME" +"1462859356938","par(mar = rep(2, 4))","YOUR NAME" +"1462859356940","","YOUR NAME" +"1462859356941","attach(Poverty)","YOUR NAME" +"1462859356994","plot(BirthRate, NationalGDP,","YOUR NAME" +"1462859356995","xlab=""BirthRate "", ylab=""NationalGDP "", main = 'BirthRate vs NationalGDP')","YOUR NAME" +"1462859357080","abline(lm(BirthRate ~ NationalGDP))","YOUR NAME" +"1462859357146","fit <- lm(BirthRate ~ NationalGDP, data=Poverty)","YOUR NAME" +"1462859357151","summary(fit)","YOUR NAME" +"1462859357169","","YOUR NAME" +"1462859357170","","YOUR NAME" +"1462859357171","","YOUR NAME" +"1462859357173","plot(InfantMortality, NationalGDP,","YOUR NAME" +"1462859357174","xlab=""InfantMortality "", ylab=""NationalGDP "", main = 'InfantMortality vs NationalGDP')","YOUR NAME" +"1462859357191","abline(lm(InfantMortality ~ NationalGDP))","YOUR NAME" +"1462859357195","fit <- lm(InfantMortality ~ NationalGDP, data=Poverty)","YOUR NAME" +"1462859357199","summary(fit)","YOUR NAME" +"1462859357208","","YOUR NAME" +"1462859357209","","YOUR NAME" +"1462859357210","","YOUR NAME" +"1462859357210","t.test(LifeExpectationMale, LifeExpectationFemale)","YOUR NAME" +"1462859357216","","YOUR NAME" +"1462859357217","","YOUR NAME" +"1462859357217","boxplot(LifeExpectationMale,LifeExpectationFemale,names = c(""LifeExpectationMale"",""LifeExpectationFemale""))","YOUR NAME" +"1462859357236","","YOUR NAME" +"1462859357238","","YOUR NAME" +"1462859357239","N1 = NationalGDP [RegionCode == 1]","YOUR NAME" +"1462859357241","N1","YOUR NAME" +"1462859357243","N2 = NationalGDP [RegionCode == 2]","YOUR NAME" +"1462859357244","N2","YOUR NAME" +"1462859357246","N3 = NationalGDP [RegionCode == 3]","YOUR NAME" +"1462859357248","N3","YOUR NAME" +"1462859357250","N1_mean = mean(N1); N2_mean = mean(N2); N3_mean = mean(N3)","YOUR NAME" +"1462859357251","N1_mean ;N2_mean ;N3_mean","YOUR NAME" +"1462859357253","","YOUR NAME" +"1462859357254","Data <- data.frame(","YOUR NAME" +"1462859357255","Y=c(N1, N2, N3),","YOUR NAME" +"1462859357256","Nations =factor(rep(c(""N1"", ""N2"", ""N3""), times=c(length(N1), length(N2), length(N3))))","YOUR NAME" +"1462859357257",")","YOUR NAME" +"1462859357259","fm1 <- aov(Y~Nations, data=Data)","YOUR NAME" +"1462859357264","anova(fm1)","YOUR NAME" +"1462859357274","","YOUR NAME" +"1462859357275","","YOUR NAME" +"1462859357276","","YOUR NAME" +"1462859357277","","YOUR NAME" +"1462987162360","fit <- glm(InfantMortality~NationalGDP,data=Poverty,family=gaussian(link=identity))","YOUR NAME" +"1462987162456","summary(fit) ","YOUR NAME" +"1462987162457","confint(fit) ","YOUR NAME" +"1462987162458","exp(coef(fit)) ","YOUR NAME" +"1462987162460","exp(confint(fit)) ","YOUR NAME" +"1462987162461","predict(fit, type=""response"") ","YOUR NAME" +"1462987162462","residuals(fit, type=""deviance"") ","YOUR NAME" +"1462987171347","setwd(""C","YOUR NAME" +"/Users/Nino Zhang/Documents/Nino Zhang/study at Rutgers/spring 2016/data final project"")","","YOUR NAME" +"1462987171351","Poverty <- read.table(""Poverty.txt"", sep=""\t"", header = TRUE)","YOUR NAME" +"1462987171445","head(Poverty)","YOUR NAME" +"1462987171445","par(mar = rep(2, 4))","YOUR NAME" +"1462987171692","","YOUR NAME" +"1462987171692","attach(Poverty)","YOUR NAME" +"1462987171723","plot(BirthRate, NationalGDP,","YOUR NAME" +"1462987171723","xlab=""BirthRate "", ylab=""NationalGDP "", main = 'BirthRate vs NationalGDP')","YOUR NAME" +"1462987171949","abline(lm(BirthRate ~ NationalGDP))","YOUR NAME" +"1462987172221","fit <- lm(BirthRate ~ NationalGDP, data=Poverty)","YOUR NAME" +"1462987172221","summary(fit)","YOUR NAME" +"1462987172491","","YOUR NAME" +"1462987172491","","YOUR NAME" +"1462987172491","","YOUR NAME" +"1462987172491","plot(InfantMortality, NationalGDP,","YOUR NAME" +"1462987172491","xlab=""InfantMortality "", ylab=""NationalGDP "", main = 'InfantMortality vs NationalGDP')","YOUR NAME" +"1462987172518","abline(lm(InfantMortality ~ NationalGDP))","YOUR NAME" +"1462987172520","","YOUR NAME" +"1462987172521","","YOUR NAME" +"1462987172522","fit <- lm(InfantMortality ~ NationalGDP, data=Poverty)","YOUR NAME" +"1462987172524","summary(fit)","YOUR NAME" +"1462987172526","","YOUR NAME" +"1462987172526","","YOUR NAME" +"1462987172526","fit <- glm(InfantMortality~NationalGDP,data=Poverty,family=gaussian(link=identity))","YOUR NAME" +"1462987172526","summary(fit) ","YOUR NAME" +"1462987172526","confint(fit) ","YOUR NAME" +"1462987172801","exp(coef(fit)) ","YOUR NAME" +"1462987172801","exp(confint(fit)) ","YOUR NAME" +"1462987172817","predict(fit, type=""response"") ","YOUR NAME" +"1462987172817","residuals(fit, type=""deviance"") ","YOUR NAME" +"1473788753383","","YOUR NAME" +"1473788753465","","YOUR NAME" +"1473788753465","(S <- 1","YOUR NAME" +"10)","","YOUR NAME" +"1473788753533","","YOUR NAME" +"1473788753534","(A <- c(1, 2, 4, 5, 9))","YOUR NAME" +"1473788753537","","YOUR NAME" +"1473788753537","(B <- c(2, 5, 7, 8, 10))","YOUR NAME" +"1473788753537","","YOUR NAME" +"1473788753537","(Ac <- setdiff(S, A))","YOUR NAME" +"1473788753537","","YOUR NAME" +"1473788753537","B. Keller, Teachers College, Columbia University 4","YOUR NAME" +"1473788753553","(Bc <- setdiff(S, B))","YOUR NAME" +"1473788753553","","YOUR NAME" +"1473788753553","(AorB <- union(A,B))","YOUR NAME" +"1473788753568","","YOUR NAME" +"1473788753568","(AandB <- intersect(A,B))","YOUR NAME" +"1473788753568","","YOUR NAME" +"1473788753568","(AorBc <- setdiff(S, AorB))","YOUR NAME" +"1473788753568","","YOUR NAME" +"1473788753568","(AcandBc <- intersect(Ac, Bc))","YOUR NAME" +"1473788753568","","YOUR NAME" +"1473788753568","AorBc","YOUR NAME" +"1473788753568","AcandBc","YOUR NAME" +"1473788789604","(AcandBc <- intersect(Ac, Bc))","YOUR NAME" +"1473797778042","install.packages(""RColorBrewer"")","YOUR NAME" +"1473797976300","","YOUR NAME" +"1473797976300","","YOUR NAME" +"1473797976300","(S <- 1","YOUR NAME" +"10)","","YOUR NAME" +"1473797976300","","YOUR NAME" +"1473797976300","(A <- c(1, 2, 4, 5, 9))","YOUR NAME" +"1473797976300","","YOUR NAME" +"1473797976300","(B <- c(2, 5, 7, 8, 10))","YOUR NAME" +"1473797976300","","YOUR NAME" +"1473797976300","(Ac <- setdiff(S, A))","YOUR NAME" +"1473797976300","","YOUR NAME" +"1473797976300","(Bc <- setdiff(S, B))","YOUR NAME" +"1473797976300","","YOUR NAME" +"1473797976300","(AorB <- union(A,B))","YOUR NAME" +"1473797976316","","YOUR NAME" +"1473797976316","(AandB <- intersect(A,B))","YOUR NAME" +"1473797976316","","YOUR NAME" +"1473797976316","(AorBc <- setdiff(S, AorB))","YOUR NAME" +"1473797976316","","YOUR NAME" +"1473797976316","(AcandBc <- intersect(Ac, Bc))","YOUR NAME" +"1473797976316","","YOUR NAME" +"1473797976316","AorBc","YOUR NAME" +"1473797976316","AcandBc","YOUR NAME" +"1473798027310","```{r, echo=TRUE}","YOUR NAME" +"1473798027311","height<-c(64, 67, 68, 70, 65)","YOUR NAME" +"1473798027312","weight<-c(120, 140, 165, 190, 130)","YOUR NAME" +"1473798027313","summary(height)","YOUR NAME" +"1473798027363","weight","YOUR NAME" +"1473798027363","height","YOUR NAME" +"1473798027363","dat1=cbind(weight, height)","YOUR NAME" +"1473798027363","dat1","YOUR NAME" +"1473798027378","```","YOUR NAME" +"1473798251262","dat1 = as.data.frame(dat1)","YOUR NAME" +"1473798251268","plot(dat1$height, dat1$weight, pch=2)","YOUR NAME" +"1473798251345","plot(weight~height, data=dat1, pch=16)","YOUR NAME" +"1473798263193","dat1 = as.data.frame(dat1)","YOUR NAME" +"1473798263193","plot(dat1$height, dat1$weight, pch=2)","YOUR NAME" +"1473798263208","plot(weight~height, data=dat1, pch=16)","YOUR NAME" +"1473798268793","dat1 = as.data.frame(dat1)","YOUR NAME" +"1473798268793","plot(dat1$height, dat1$weight, pch=2)","YOUR NAME" +"1473798268809","plot(weight~height, data=dat1, pch=16)","YOUR NAME" +"1473799512769","seq(-1,1, len=30)","YOUR NAME" +"1473799562451","seq(-1,1, len=30)","YOUR NAME" +"1473799562451","var1 <- sin(x)","YOUR NAME" +"1473799583073","x <- seq(-1,1, len=30)","YOUR NAME" +"1473799583073","var1 <- sin(x)","YOUR NAME" +"1473799603652","x <- seq(-1,1, len=30)","YOUR NAME" +"1473799603656","y <- sin(x)","YOUR NAME" +"1473799639255","x <- seq(-1,1, len=30)","YOUR NAME" +"1473799639260","y <- sin(x)","YOUR NAME" +"1473799639260","scatterplot (y,x)","YOUR NAME" +"1473799647124","x <- seq(-1,1, len=30)","YOUR NAME" +"1473799647127","y <- sin(x)","YOUR NAME" +"1473799647130","ggplot (y,x)","YOUR NAME" +"1473799658498","x <- seq(-1,1, len=30)","YOUR NAME" +"1473799658502","y <- sin(x)","YOUR NAME" +"1473799658505","plot(y,x)","YOUR NAME" +"1473799771901","x <- seq(-1,1, len=30)","YOUR NAME" +"1473799771903","y <- sin(x)","YOUR NAME" +"1473799771910","plot(y,x)","YOUR NAME" +"1473799771921","plot((y,x), pch=5, cex=2)","YOUR NAME" +"1473799790057","x <- seq(-1,1, len=30)","YOUR NAME" +"1473799790059","y <- sin(x)","YOUR NAME" +"1473799790060","plot(y,x)","YOUR NAME" +"1473799790072","plot(y,x, pch=5, cex=2)","YOUR NAME" +"1473799837025","x <- seq(-1,1, len=30)","YOUR NAME" +"1473799837028","y <- sin(x)","YOUR NAME" +"1473799837032","plot(y,x)","YOUR NAME" +"1473799837045","plot(y,x, pch=5, cex=2, color = ""firebrick1"")","YOUR NAME" +"1473799838468","x <- seq(-1,1, len=30)","YOUR NAME" +"1473799838470","y <- sin(x)","YOUR NAME" +"1473799838472","plot(y,x)","YOUR NAME" +"1473799838484","plot(y,x, pch=5, cex=2, color = ""firebrick1"")","YOUR NAME" +"1473799852182","x <- seq(-1,1, len=30)","YOUR NAME" +"1473799852188","y <- sin(x)","YOUR NAME" +"1473799852193","plot(y,x)","YOUR NAME" +"1473799852217","plot(y,x, pch=5, cex=2, col = ""firebrick1"")","YOUR NAME" +"1473800171855","x <- seq(-1,1, len=30)","YOUR NAME" +"1473800171857","y <- sin(x)","YOUR NAME" +"1473800171859","plot(y,x)","YOUR NAME" +"1473800171878","plot(y,x, pch=5, cex=2, col = ""firebrick1"")","YOUR NAME" +"1473800210106","x <- seq(-1,1, len=30)","YOUR NAME" +"1473800210110","y <- sin(x)","YOUR NAME" +"1473800210115","plot(y,x)","YOUR NAME" +"1473800210131","plot(y,x, pch=?, cex=2, col = ""firebrick1"")","YOUR NAME" +"1473800233983","x <- seq(-1,1, len=30)","YOUR NAME" +"1473800233985","y <- sin(x)","YOUR NAME" +"1473800234131","plot(y,x)","YOUR NAME" +"1473800234145","plot(y,x, pch=14, cex=2, col = ""firebrick1"")","YOUR NAME" +"1473800240638","x <- seq(-1,1, len=30)","YOUR NAME" +"1473800240643","y <- sin(x)","YOUR NAME" +"1473800240646","plot(y,x)","YOUR NAME" +"1473800240659","plot(y,x, pch=5, cex=2, col = ""firebrick1"")","YOUR NAME" +"1473800435374","install.packages(DT)","YOUR NAME" +"1473800455935","install.packages(""DT"")","YOUR NAME" +"1473800635251","setwd(""~/Nino Zhang/study at TC/fall 2016/IDS/tutorials"")","YOUR NAME" +"1473800701626","BaseballSalary=read_csv(file=""data/BaseballSalary.csv"")","YOUR NAME" +"1473800747713","BaseballSalary=read.csv(file=""data/BaseballSalary.csv"")","YOUR NAME" +"1473800821278","datatable(head(BaseballSalary,50), options = list(scrollX=T, pageLength = 8))","YOUR NAME" +"1473800948781","datatable(head(BaseballSalary,50), options = list(scrollX=T, pageLength = 8))","YOUR NAME" +"1473801049468","library(dplyr)","YOUR NAME" +"1473801049514","library(readr)","YOUR NAME" +"1473801049518","library(DT)","YOUR NAME" +"1473801049777","library(RColorBrewer)","YOUR NAME" +"1473801067869","install.packages(c(""dplyr"", ""readr""))","YOUR NAME" +"1473801134900","library(dplyr)","YOUR NAME" +"1473801135613","library(readr)","YOUR NAME" +"1473801135718","library(DT)","YOUR NAME" +"1473801135722","library(RColorBrewer)","YOUR NAME" +"1473801137406","library(dplyr)","YOUR NAME" +"1473801137411","library(readr)","YOUR NAME" +"1473801137415","library(DT)","YOUR NAME" +"1473801137418","library(RColorBrewer)","YOUR NAME" +"1473801137589","library(dplyr)","YOUR NAME" +"1473801137599","library(readr)","YOUR NAME" +"1473801137600","library(DT)","YOUR NAME" +"1473801137602","library(RColorBrewer)","YOUR NAME" +"1473801143151","BaseballSalary=read.csv(file=""data/BaseballSalary.csv"")","YOUR NAME" +"1473801152433","BaseballSalary=read_csv(file=""data/BaseballSalary.csv"")","YOUR NAME" +"1473801156183","datatable(head(BaseballSalary,50), options = list(scrollX=T, pageLength = 8))","YOUR NAME" +"1473957564652","rnorm(10,0,1)","YOUR NAME" +"1474402138449","```{r}","YOUR NAME" +"1474402138496","plot(life.exp~inc, data=statedata, type=""n"")","YOUR NAME" +"1474402138501","text(life.exp~inc, data=statedata, state.abb)","YOUR NAME" +"1474402138506","```","YOUR NAME" +"1474402145070","---","YOUR NAME" +"1474402145071","title","YOUR NAME" +" 'Tutorial 2b"," regression'","YOUR NAME" +"1474402145098","author","YOUR NAME" +" ""Tian Zheng""","","YOUR NAME" +"1474402145101","date","YOUR NAME" +" ""September 20, 2016""","","YOUR NAME" +"1474402145151","output","YOUR NAME" +"1474402145152","pdf_document","YOUR NAME" +" default","","YOUR NAME" +"1474402145154","html_notebook","YOUR NAME" +" default","","YOUR NAME" +"1474402145155","---","YOUR NAME" +"1474402145156","In this example, we are going to use the dataset `state.x77` that comes with standard `R` installation. It is a data set about the 50 states of united states.","YOUR NAME" +"1474402145158","Type `help(state.x77)` in your console window to read more about this data set.","YOUR NAME" +"1474402145160","```{r}","YOUR NAME" +"1474402145161","library(datasets)","YOUR NAME" +"1474402145163","statedata=as.data.frame(state.x77)","YOUR NAME" +"1474402145190","```","YOUR NAME" +"1474402145192","There are 8 variables in this data set. The ""individuals"" of this data set are the 50 states.","YOUR NAME" +"1474402145193","Population","YOUR NAME" +" population estimate as of July 1, 1975","","YOUR NAME" +"1474402145194","Income","YOUR NAME" +" per capita income (1974)","","YOUR NAME" +"1474402145196","Illiteracy","YOUR NAME" +"illiteracy (1970, percent of population)","","YOUR NAME" +"1474402145197","Life Exp","YOUR NAME" +" life expectancy in years (1969–71)","","YOUR NAME" +"1474402145199","Murder","YOUR NAME" +" murder and non-negligent manslaughter rate per 100,000 population (1976)","","YOUR NAME" +"1474402145202","HS Grad","YOUR NAME" +" percent high-school graduates (1970)","","YOUR NAME" +"1474402145204","Frost","YOUR NAME" +" mean number of days with minimum temperature below freezing (1931–1960) in capital or large city","","YOUR NAME" +"1474402145205","Area","YOUR NAME" +" land area in square miles","","YOUR NAME" +"1474402145206","First we can modify the column names (the variable names) for easier use. The function `colnames` can be used to retrieve the colume names or assign new names.","YOUR NAME" +"1474402145208","```{r}","YOUR NAME" +"1474402145209","colnames(statedata)=c(""popu"", ""inc"", ""illit"", ""life.exp"", ""murder"", ""hs.grad"", ""frost"", ""area"")","YOUR NAME" +"1474402145212","```","YOUR NAME" +"1474402145213","","YOUR NAME" +"1474402145215","For this example, let's look at the association between life expectancy (`life.exp`) and income (`inc`). The scatterplot below shows a positive association between these two variables.","YOUR NAME" +"1474402145217","```{r}","YOUR NAME" +"1474402145218","plot(life.exp~inc, data=statedata)","YOUR NAME" +"1474402145316","```","YOUR NAME" +"1474402145318","We can compute the correlation between these two variables. The value of the correlation indicates a weak positive linear association.","YOUR NAME" +"1474402145319","```{r}","YOUR NAME" +"1474402145320","cor(statedata[,""life.exp""], statedata[,""inc""])","YOUR NAME" +"1474402145323","```","YOUR NAME" +"1474402145325","There is one observation that is far away from the rest of the points. We would like to know which state is corresponding to that point. Let's add state abbreviations to the plot.","YOUR NAME" +"1474402145328","```{r}","YOUR NAME" +"1474402145329","plot(life.exp~inc, data=statedata, type=""n"")","YOUR NAME" +"1474402145355","text(life.exp~inc, data=statedata, state.abb)","YOUR NAME" +"1474402145364","```","YOUR NAME" +"1474402145365","","YOUR NAME" +"1474402145365","Now let's fit the following linear regression model between $Y$ (`life.exp`) and $X$ (`inc`)","YOUR NAME" +"1474402145366","$$ Y= \beta_0 +\beta_1 X + \varepsilon. $$","YOUR NAME" +"1474402145367","Here $\beta_0$ and $\beta_1$ are the regression coefficients of the model and $\varepsilon$ represents independent random errors.","YOUR NAME" +"1474402145368","Fitting a linear regression is to derive","YOUR NAME" +"1474402145369","$$\hat{Y} = b_0 + b_1 X.$$","YOUR NAME" +"1474402145370","Here $\hat{Y}$ is a fitted prediction for the observed life expectancies. The difference $Y - \hat{Y}$ is the prediction error, or residual.","YOUR NAME" +"1474402145371","$b_0$ and $b_1$ are estimates for the regression coefficients. They are identified via the least square regression method that minimizes","YOUR NAME" +"1474402145372","$$\sum_{i=1}^n (Y - \hat{Y})^2,$$","YOUR NAME" +"1474402145373","i.e., the sum of squared prediction errors.","YOUR NAME" +"1474402145374","```{r}","YOUR NAME" +"1474402145375","model1=lm(life.exp~inc, data=statedata)","YOUR NAME" +"1474402145379","model1","YOUR NAME" +"1474402145388","```","YOUR NAME" +"1474402145389","In the above output, the intercept is $b_0$ and the coeffient under the column (`inc`) is $b_1$--the slope. The slope is estimated to be $7.4\times 10^{-4}$. The maganitude of this value does not mean that the effect of income on life expectance is very small. This maganitude is decided by the maganitude of the $X$ variable and $Y$ variable.","YOUR NAME" +"1474402145390","","YOUR NAME" +"1474402145391","Consider a population of 50 states and we identify the true regression line in this population. Here the function `abline` add a straight line to an existing plot.","YOUR NAME" +"1474402145392","```{r}","YOUR NAME" +"1474402145393","plot(life.exp~inc, data=statedata,","YOUR NAME" +"1474402145394","xlab=""Life Expectancy"", ylab=""Income"")","YOUR NAME" +"1474402145420","abline(model1)","YOUR NAME" +"1474402145422","```","YOUR NAME" +"1474402145424","Now we can consider 4 random samples. We use a [`for` loop](https","YOUR NAME" +"//en.wikipedia.org/wiki/For_loop) to run an identical regression analysis on 4 randomly selected samples.","","YOUR NAME" +"1474402145425","Within the loop, we will implement the following steps for each repetition.","YOUR NAME" +"1474402145427","+ Step 1","YOUR NAME" +" randomly select 10 states using the `sample` function of `R`.","","YOUR NAME" +"1474402145428","+ Step 2","YOUR NAME" +" run least square regression on the selected states only","","YOUR NAME" +"1474402145429","+ Step 3","YOUR NAME" +" compute a 95% confidence band for the true regression line in the population using the sample.","","YOUR NAME" +"1474402145431","**[Note]** The states are randomly selected in the following. Therefore, every time you run this file, you will produce different random samples that will give different estimated least regression lines.","YOUR NAME" +"1474402145432","```{r, fig.height=8, fig.width=8}","YOUR NAME" +"1474402145433","par(mfrow=c(2,2)) ","YOUR NAME" +"1474402145436","for(i in 1","YOUR NAME" +"4){","","YOUR NAME" +"1474402145437","","YOUR NAME" +"1474402145438","plot(life.exp~inc, data=statedata,","YOUR NAME" +"1474402145439","xlab=""Life Expectancy"", ylab=""Income"",","YOUR NAME" +"1474402145441","title=paste(""Random sample"", format(i)),","YOUR NAME" +"1474402145442","ylim=c(min(life.exp), max(life.exp)+0.3))","YOUR NAME" +"1474402145443","abline(model1)","YOUR NAME" +"1474402145445","if(i==1){","YOUR NAME" +"1474402145446","legend(3030, 74.2,","YOUR NAME" +"1474402145447","pch=c(NA, NA, NA, 1, 16),","YOUR NAME" +"1474402145448","lty=c(1, 1, 2, NA, NA),","YOUR NAME" +"1474402145449","col=c(1, 2, 2, 1, 2),","YOUR NAME" +"1474402145451","c(""population truth"", ""sample estimate"",","YOUR NAME" +"1474402145452","""sample confidence band"",","YOUR NAME" +"1474402145453","""states"", ""sampled""),","YOUR NAME" +"1474402145455","cex=0.7,","YOUR NAME" +"1474402145456","bty=""n""","YOUR NAME" +"1474402145457",")","YOUR NAME" +"1474402145458","}","YOUR NAME" +"1474402145459","","YOUR NAME" +"1474402145460","selected.states=sample(1","YOUR NAME" +"50, 10)","","YOUR NAME" +"1474402145462","points(statedata[selected.states,""inc""],","YOUR NAME" +"1474402145463","statedata[selected.states,""life.exp""], pch=16, col=2)","YOUR NAME" +"1474402145464","","YOUR NAME" +"1474402145465","model.sel = lm(life.exp~inc, data=statedata[selected.states,])","YOUR NAME" +"1474402145467","abline(model.sel, col=2)","YOUR NAME" +"1474402145468","","YOUR NAME" +"1474402145469","","YOUR NAME" +"1474402145470","ww=sqrt(2*qf(0.95, 2, nrow(statedata)-2))","YOUR NAME" +"1474402145471","","YOUR NAME" +"1474402145473","plot.x<-data.frame(inc=seq(3000, 7000, 1))","YOUR NAME" +"1474402145476","","YOUR NAME" +"1474402145477","","YOUR NAME" +"1474402145478","plot.fit<-predict(model.sel, plot.x,","YOUR NAME" +"1474402145479","level=0.95, interval=""confidence"",","YOUR NAME" +"1474402145480","se.fit=T)","YOUR NAME" +"1474402145481","","YOUR NAME" +"1474402145483","","YOUR NAME" +"1474402145484","lines(plot.x$inc, plot.fit$fit[,1]+ww*plot.fit$se.fit,","YOUR NAME" +"1474402145485","col=2, lty=2)","YOUR NAME" +"1474402145486","lines(plot.x$inc, plot.fit$fit[,1]-ww*plot.fit$se.fit,","YOUR NAME" +"1474402145487","col=2, lty=2)","YOUR NAME" +"1474402145489","}","YOUR NAME" +"1474402145581","```","YOUR NAME" +"1474402172475","specialized functions need to be loaded first before they can used.","YOUR NAME" +"1474402172478","```{r}","YOUR NAME" +"1474402172481","library(dplyr)","YOUR NAME" +"1474402173003","library(readr)","YOUR NAME" +"1474402173058","library(DT)","YOUR NAME" +"1474402173153","library(RColorBrewer)","YOUR NAME" +"1474402173203","```","YOUR NAME" +"1474402173206","","YOUR NAME" +"1474402178823","---","YOUR NAME" +"1474402178824","title","YOUR NAME" +" ""Basic data operations""","","YOUR NAME" +"1474402178826","output","YOUR NAME" +" html_notebook","","YOUR NAME" +"1474402178827","---","YOUR NAME" +"1474402178829","","YOUR NAME" +"1474402178830","This is an [R Markdown](http","YOUR NAME" +"//rmarkdown.rstudio.com) Notebook. When you execute code within the notebook, the results appear beneath the code. Try executing this chunk by clicking the *Run* button within the chunk or by placing your cursor inside it and pressing *Cmd+Shift+Enter*.","","YOUR NAME" +"1474402178831","","YOUR NAME" +"1474402178832","In this tutorial, we will look at the salary of Major League Baseball (MLB) players. [source from baseballguru.com.](http","YOUR NAME" +"//baseballguru.com/salary.zip)","","YOUR NAME" +"1474402178834","First we load R libraries that we need for this tutorial. Basic libraries of functions are loaded every time R starts. More specialized functions need to be loaded first before they can used.","YOUR NAME" +"1474402178836","```{r}","YOUR NAME" +"1474402178838","library(dplyr)","YOUR NAME" +"1474402178887","library(readr)","YOUR NAME" +"1474402178889","library(DT)","YOUR NAME" +"1474402178891","library(RColorBrewer)","YOUR NAME" +"1474402178892","```","YOUR NAME" +"1474402178894","","YOUR NAME" +"1474402178895","R can read data from data files such as csv, txt, and output from other softwares such as STATA and SAS. Google for ""R load data xx format"" should usually point you to the right direction. CSV is usually one of the most widely used format for data nowadays.","YOUR NAME" +"1474402178896","Now let's read in the baseball salary data set.","YOUR NAME" +"1474402178898","```{r}","YOUR NAME" +"1474402178899","BaseballSalary=read_csv(file=""data/BaseballSalary.csv"")","YOUR NAME" +"1474402179264","```","YOUR NAME" +"1474402179265","```{r}","YOUR NAME" +"1474402179266","datatable(head(BaseballSalary,50), options = list(scrollX=T, pageLength = 8))","YOUR NAME" +"1474402179726","```","YOUR NAME" +"1474402179727","","YOUR NAME" +"1474402179728","```{r, fig.height=8, fig.width=6}","YOUR NAME" +"1474402179729","col.use=brewer.pal(10, ""RdYlBu"")","YOUR NAME" +"1474402179732","hist.1985=hist(filter(BaseballSalary, year==1985)$salary,","YOUR NAME" +"1474402179733","main=""salaries in 1985"",","YOUR NAME" +"1474402179734","xlab=""annual salary"",","YOUR NAME" +"1474402179734","col=col.use,","YOUR NAME" +"1474402179735","nclass = 50)","YOUR NAME" +"1474402179930","hist(filter(BaseballSalary, year==2004)$salary,","YOUR NAME" +"1474402179934","main=""salaries in 2004"",","YOUR NAME" +"1474402179937","xlab=""annual salary"",","YOUR NAME" +"1474402179942","col=col.use,","YOUR NAME" +"1474402179943","nclass = 50)","YOUR NAME" +"1474402179949","par(mfrow=c(2,1))","YOUR NAME" +"1474402179951","hist.1985=hist(filter(BaseballSalary, year==1985)$salary,","YOUR NAME" +"1474402179952","main=""salaries in 1985"",","YOUR NAME" +"1474402179952","xlab=""annual salary"",","YOUR NAME" +"1474402179953","col=col.use,","YOUR NAME" +"1474402179954","nclass = 50,","YOUR NAME" +"1474402179954","ylim=c(0, 250))","YOUR NAME" +"1474402179976","hist(filter(BaseballSalary, year==2004)$salary,","YOUR NAME" +"1474402179977","col=col.use,","YOUR NAME" +"1474402179978","breaks=c(hist.1985$breaks, max(BaseballSalary$salary)),","YOUR NAME" +"1474402179979","main=""salaries in 2004"",","YOUR NAME" +"1474402179979","xlab=""annual salary"",","YOUR NAME" +"1474402179981","xlim=c(0, 2000000),","YOUR NAME" +"1474402179982","ylim=c(0,250),","YOUR NAME" +"1474402179983","freq=T)","YOUR NAME" +"1474402179992","```","YOUR NAME" +"1474402179994","Change the plot aspect ratio.","YOUR NAME" +"1474402179995","```{r, fig.height=4, fig.width=6}","YOUR NAME" +"1474402179997","par(mfrow=c(1,1))","YOUR NAME" +"1474402180010","plot(salary~as.factor(year), data=BaseballSalary, col=col.use)","YOUR NAME" +"1474402180078","```","YOUR NAME" +"1474402180079","What happened from 1994 to 1995? [Answer](https","YOUR NAME" +"//en.wikipedia.org/wiki/1994%E2%80%9395_Major_League_Baseball_strike)","","YOUR NAME" +"1474402180080","","YOUR NAME" +"1474402180081","Dplyr aims to provide a function for each basic verb of data manipulation.","YOUR NAME" +"1474402180082","- `filter()`","YOUR NAME" +"1474402180083","- `arrange()`","YOUR NAME" +"1474402180088","- `select()`","YOUR NAME" +"1474402180090","- `distinct()`","YOUR NAME" +"1474402180091","- `mutate()`","YOUR NAME" +"1474402180092","- `summarise()`","YOUR NAME" +"1474402180093","- `sample_n()` and `sample_frac()`","YOUR NAME" +"1474402180094","- `group_by`","YOUR NAME" +"1474402180098","","YOUR NAME" +"1474402180099","```{r}","YOUR NAME" +"1474402180100","BSTeamYear=BaseballSalary%>%","YOUR NAME" +"1474402180100","group_by(teamID, year)%>%","YOUR NAME" +"1474402180101","summarize(","YOUR NAME" +"1474402180102","count=n(),","YOUR NAME" +"1474402180102","total=sum(salary),","YOUR NAME" +"1474402180103","median=median(salary),","YOUR NAME" +"1474402180104","min=min(salary),","YOUR NAME" +"1474402180105","max=max(salary),","YOUR NAME" +"1474402180107","q1=quantile(salary, .25),","YOUR NAME" +"1474402180108","q3=quantile(salary, .75)","YOUR NAME" +"1474402180109",")","YOUR NAME" +"1474402180529","BSTeamYear=as.data.frame(BSTeamYear)","YOUR NAME" +"1474402180531","sample_n(BSTeamYear, 10)","YOUR NAME" +"1474402180538","```","YOUR NAME" +"1474402180540","","YOUR NAME" +"1474402180541","```{r, fig.height=3, fig.width=6}","YOUR NAME" +"1474402180542","datatable(filter(BSTeamYear, year==2004), options = list(scrollX=T, pageLength = 10))","YOUR NAME" +"1474402180643","BS2004=filter(BaseballSalary, year==2004)","YOUR NAME" +"1474402180646","plot(as.factor(BS2004$teamID), BS2004$salary, col=col.use, las=2)","YOUR NAME" +"1474402180699","BS2004[which.max(BS2004$salary),]","YOUR NAME" +"1474402180713","```","YOUR NAME" +"1474402842977","datatable(filter(BSTeamYear, year==2004), options = list(scrollX=T, pageLength = 10))","YOUR NAME" +"1474402843112","BS2004=filter(BaseballSalary, year==2004)","YOUR NAME" +"1474402843116","plot(as.factor(BS2004$teamID), BS2004$salary, col=col.use, las=2)","YOUR NAME" +"1474402843157","BS2004[which.max(BS2004$salary),]","YOUR NAME" +"1474402886446","which.max(BS2004$salary)","YOUR NAME" +"1474403079916","mlb2014=read_csv(file=""data/mlb2014.csv"")","YOUR NAME" +"1474403585637","dim(mlb2014)","YOUR NAME" +"1474403585642","datatable(select(sample_n(mlb2014,50), ends_with(""G"")), options = list(scrollX=T, pageLength = 5))","YOUR NAME" +"1474403987262","table(mlb2014$pos1)","YOUR NAME" +"1474403987265","table(mlb2014$bats)","YOUR NAME" +"1474403987268","table(mlb2014$pos1, mlb2014$bats)","YOUR NAME" +"1474404287416","col.use=brewer.pal(4, 'Set2')","YOUR NAME" +"1474404287418","plot(table(mlb2014$pos1, mlb2014$bats), col=col.use)","YOUR NAME" +"1474404452882","chisq.test(table(mlb2014$pos1, mlb2014$bats))","YOUR NAME" +"1474404461132","chisq.test(table(mlb2014$pos1, mlb2014$bats))","YOUR NAME" +"1474404525508","hist(mlb2014$slg)","YOUR NAME" +"1474404525512","plot(as.factor(mlb2014$pos1), mlb2014$slg, col=col.use)","YOUR NAME" +"1474404525540","summary(lm(slg~as.factor(pos1), data=mlb2014))","YOUR NAME" +"1474404525551","anova(lm(slg~as.factor(pos1), data=mlb2014))","YOUR NAME" +"1474404536601","hist(mlb2014$slg)","YOUR NAME" +"1474404536603","plot(as.factor(mlb2014$pos1), mlb2014$slg, col=col.use)","YOUR NAME" +"1474404536630","summary(lm(slg~as.factor(pos1), data=mlb2014))","YOUR NAME" +"1474404536637","anova(lm(slg~as.factor(pos1), data=mlb2014))","YOUR NAME" +"1474404563821","hist(mlb2014$slg)","YOUR NAME" +"1474404563830","plot(as.factor(mlb2014$pos1), mlb2014$slg, col=col.use)","YOUR NAME" +"1474404563858","summary(lm(slg~as.factor(pos1), data=mlb2014))","YOUR NAME" +"1474404563865","anova(lm(slg~as.factor(pos1), data=mlb2014))","YOUR NAME" +"1474404565756","plot(as.factor(mlb2014$pos1), mlb2014$slg, col=col.use)","YOUR NAME" +"1474404623511","hist(mlb2014$obp)","YOUR NAME" +"1474404623516","plot(as.factor(mlb2014$pos1), mlb2014$obp, col=col.use)","YOUR NAME" +"1474404623546","summary(lm(obp~as.factor(pos1), data=mlb2014))","YOUR NAME" +"1474404623553","anova(lm(obp~as.factor(pos1), data=mlb2014))","YOUR NAME" +"1474404726886","anova(lm(obp~as.factor(pos1), data=mlb2014))","YOUR NAME" +"1474404736011","anova(lm(obp~as.factor(pos1), data=mlb2014))","YOUR NAME" +"1474405147287","cor(mlb2014$slg, mlb2014$obp)","YOUR NAME" +"1474405147292","cor(mlb2014$slg, mlb2014$obp, use=""complete.obs"")","YOUR NAME" +"1474405147295","plot(slg~obp, data=mlb2014)","YOUR NAME" +"1474405147325","cor.test(~slg+obp, data=mlb2014)","YOUR NAME" +"1474405162162","library(dplyr)","YOUR NAME" +"1474405162164","library(readr)","YOUR NAME" +"1474405162165","library(DT)","YOUR NAME" +"1474405162167","library(RColorBrewer)","YOUR NAME" +"1474405166194","mlb2014=read_csv(file=""data/mlb2014.csv"")","YOUR NAME" +"1474405167975","mlb2014=read_csv(file=""data/mlb2014.csv"", na=c("""", ""-"", ""NA""))","YOUR NAME" +"1474405170445","dim(mlb2014)","YOUR NAME" +"1474405170447","datatable(select(sample_n(mlb2014,50), ends_with(""G"")), options = list(scrollX=T, pageLength = 5))","YOUR NAME" +"1474405176287","table(mlb2014$pos1)","YOUR NAME" +"1474405176290","table(mlb2014$bats)","YOUR NAME" +"1474405176293","table(mlb2014$pos1, mlb2014$bats)","YOUR NAME" +"1474405178382","col.use=brewer.pal(4, 'Set2')","YOUR NAME" +"1474405178386","plot(table(mlb2014$pos1, mlb2014$bats), col=col.use)","YOUR NAME" +"1474405184351","chisq.test(table(mlb2014$pos1, mlb2014$bats))","YOUR NAME" +"1474405188507","hist(mlb2014$slg)","YOUR NAME" +"1474405188522","plot(as.factor(mlb2014$pos1), mlb2014$slg, col=col.use)","YOUR NAME" +"1474405188543","summary(lm(slg~as.factor(pos1), data=mlb2014))","YOUR NAME" +"1474405188632","anova(lm(slg~as.factor(pos1), data=mlb2014))","YOUR NAME" +"1474405201819","plot(as.factor(mlb2014$pos1), mlb2014$slg, col=col.use)","YOUR NAME" +"1474405210602","hist(mlb2014$obp)","YOUR NAME" +"1474405212757","hist(mlb2014$obp)","YOUR NAME" +"1474405212770","plot(as.factor(mlb2014$pos1), mlb2014$obp, col=col.use)","YOUR NAME" +"1474405212791","summary(lm(obp~as.factor(pos1), data=mlb2014))","YOUR NAME" +"1474405212805","anova(lm(obp~as.factor(pos1), data=mlb2014))","YOUR NAME" +"1474405218073","cor(mlb2014$slg, mlb2014$obp)","YOUR NAME" +"1474405218075","cor(mlb2014$slg, mlb2014$obp, use=""complete.obs"")","YOUR NAME" +"1474405218077","plot(slg~obp, data=mlb2014)","YOUR NAME" +"1474405218103","cor.test(~slg+obp, data=mlb2014)","YOUR NAME" +"1474405223738","cor(mlb2014$slg, mlb2014$obp, use=""complete.obs"")","YOUR NAME" +"1474405227381","cor(mlb2014$slg, mlb2014$obp)","YOUR NAME" +"1474405227383","cor(mlb2014$slg, mlb2014$obp, use=""complete.obs"")","YOUR NAME" +"1474405227384","plot(slg~obp, data=mlb2014)","YOUR NAME" +"1474405227412","cor.test(~slg+obp, data=mlb2014)","YOUR NAME" +"1474405319976","hist(mlb2014$age)","YOUR NAME" +"1474405319991","plot(obp~age, data=mlb2014)","YOUR NAME" +"1474405320024","summary(lm(obp~age, data=mlb2014))","YOUR NAME" +"1474405320033","cor.test(~age+obp, data=mlb2014)","YOUR NAME" +"1474405346195","library(datasets)","YOUR NAME" +"1474405346196","statedata=as.data.frame(state.x77)","YOUR NAME" +"1474405351882","colnames(statedata)=c(""popu"", ""inc"", ""illit"", ""life.exp"", ""murder"", ""hs.grad"", ""frost"", ""area"")","YOUR NAME" +"1474405354508","plot(life.exp~inc, data=statedata)","YOUR NAME" +"1474405357099","cor(statedata[,""life.exp""], statedata[,""inc""])","YOUR NAME" +"1474405359790","plot(life.exp~inc, data=statedata, type=""n"")","YOUR NAME" +"1474405359806","text(life.exp~inc, data=statedata, state.abb)","YOUR NAME" +"1474405363977","model1=lm(life.exp~inc, data=statedata)","YOUR NAME" +"1474405363980","model1","YOUR NAME" +"1474405367133","plot(life.exp~inc, data=statedata,","YOUR NAME" +"1474405367134","xlab=""Life Expectancy"", ylab=""Income"")","YOUR NAME" +"1474405367156","abline(model1)","YOUR NAME" +"1474405369665","par(mfrow=c(2,2)) ","YOUR NAME" +"1474405369667","for(i in 1","YOUR NAME" +"4){","","YOUR NAME" +"1474405369667","","YOUR NAME" +"1474405369668","plot(life.exp~inc, data=statedata,","YOUR NAME" +"1474405369669","xlab=""Life Expectancy"", ylab=""Income"",","YOUR NAME" +"1474405369670","title=paste(""Random sample"", format(i)),","YOUR NAME" +"1474405369671","ylim=c(min(life.exp), max(life.exp)+0.3))","YOUR NAME" +"1474405369672","abline(model1)","YOUR NAME" +"1474405369673","if(i==1){","YOUR NAME" +"1474405369674","legend(3030, 74.2,","YOUR NAME" +"1474405369675","pch=c(NA, NA, NA, 1, 16),","YOUR NAME" +"1474405369676","lty=c(1, 1, 2, NA, NA),","YOUR NAME" +"1474405369677","col=c(1, 2, 2, 1, 2),","YOUR NAME" +"1474405369679","c(""population truth"", ""sample estimate"",","YOUR NAME" +"1474405369680","""sample confidence band"",","YOUR NAME" +"1474405369680","""states"", ""sampled""),","YOUR NAME" +"1474405369681","cex=0.7,","YOUR NAME" +"1474405369682","bty=""n""","YOUR NAME" +"1474405369683",")","YOUR NAME" +"1474405369683","}","YOUR NAME" +"1474405369684","","YOUR NAME" +"1474405369685","selected.states=sample(1","YOUR NAME" +"50, 10)","","YOUR NAME" +"1474405369685","points(statedata[selected.states,""inc""],","YOUR NAME" +"1474405369686","statedata[selected.states,""life.exp""], pch=16, col=2)","YOUR NAME" +"1474405369687","","YOUR NAME" +"1474405369687","model.sel = lm(life.exp~inc, data=statedata[selected.states,])","YOUR NAME" +"1474405369688","abline(model.sel, col=2)","YOUR NAME" +"1474405369689","","YOUR NAME" +"1474405369690","","YOUR NAME" +"1474405369690","ww=sqrt(2*qf(0.95, 2, nrow(statedata)-2))","YOUR NAME" +"1474405369691","","YOUR NAME" +"1474405369692","plot.x<-data.frame(inc=seq(3000, 7000, 1))","YOUR NAME" +"1474405369693","","YOUR NAME" +"1474405369694","","YOUR NAME" +"1474405369694","plot.fit<-predict(model.sel, plot.x,","YOUR NAME" +"1474405369695","level=0.95, interval=""confidence"",","YOUR NAME" +"1474405369696","se.fit=T)","YOUR NAME" +"1474405369697","","YOUR NAME" +"1474405369698","","YOUR NAME" +"1474405369699","lines(plot.x$inc, plot.fit$fit[,1]+ww*plot.fit$se.fit,","YOUR NAME" +"1474405369700","col=2, lty=2)","YOUR NAME" +"1474405369701","lines(plot.x$inc, plot.fit$fit[,1]-ww*plot.fit$se.fit,","YOUR NAME" +"1474405369702","col=2, lty=2)","YOUR NAME" +"1474405369703","}","YOUR NAME" +"1474523470723","getwd()","YOUR NAME" +"1474523470821","df <- read.csv(""ToyotaPrices.csv"",","YOUR NAME" +"1474523470825","header = FALSE)","YOUR NAME" +"1474523566489","getwd()","YOUR NAME" +"1474523566491","df <- read.csv(""ToyotaPrices.csv"",","YOUR NAME" +"1474523566494","header = FALSE)","YOUR NAME" +"1474523607741","getwd()","YOUR NAME" +"1474523607744","df <- read.csv(""ToyotaPrices.csv"",","YOUR NAME" +"1474523607747","header = FALSE)","YOUR NAME" +"1474523833341","getwd()","YOUR NAME" +"1474524314471","data = read_csv(file=""C","YOUR NAME" +"/Users/Nino Zhang/Downloads/ToyotaPrices.csv"")","","YOUR NAME" +"1474524338820","data = read.csv(file=""C","YOUR NAME" +"/Users/Nino Zhang/Downloads/ToyotaPrices.csv"")","","YOUR NAME" +"1474524510261","getwd()","YOUR NAME" +"1474524510263","data = read.csv(file=""C","YOUR NAME" +"/Users/Nino Zhang/Downloads/ToyotaPrices.csv"")","","YOUR NAME" +"1474524510285","set.seed(123)","YOUR NAME" +"1474524510289","n <- 100","YOUR NAME" +"1474524510292","beta_0 <- 10","YOUR NAME" +"1474524510293","beta_1 <- 2","YOUR NAME" +"1474524510295","mu <- 0","YOUR NAME" +"1474524510296","st_dev <- 0.7","YOUR NAME" +"1474524510298","err <- rnorm(n, mean = mu, sd = st_dev)","YOUR NAME" +"1474524510299","x_obs <- runif(n, min = 0, max = 1)","YOUR NAME" +"1474524510301","y_obs <- beta_0 + beta_1*x_obs + err","YOUR NAME" +"1474524518863","getwd()","YOUR NAME" +"1474524518864","data = read.csv(file=""C","YOUR NAME" +"/Users/Nino Zhang/Downloads/ToyotaPrices.csv"")","","YOUR NAME" +"1474524518886","set.seed(123)","YOUR NAME" +"1474524518887","n <- 100","YOUR NAME" +"1474524518888","beta_0 <- 10","YOUR NAME" +"1474524518889","beta_1 <- 2","YOUR NAME" +"1474524518890","mu <- 0","YOUR NAME" +"1474524518890","st_dev <- 0.7","YOUR NAME" +"1474524518891","err <- rnorm(n, mean = mu, sd = st_dev)","YOUR NAME" +"1474524518892","x_obs <- runif(n, min = 0, max = 1)","YOUR NAME" +"1474524518893","y_obs <- beta_0 + beta_1*x_obs + err","YOUR NAME" +"1474524518895","myData <- data.frame(err, x_obs, y_obs)","YOUR NAME" +"1474524518898","head(myData)","YOUR NAME" +"1474524518902","summary(myData)","YOUR NAME" +"1474524532304","str(myData)","YOUR NAME" +"1474524532309","summary(myData)","YOUR NAME" +"1474524532313","df$Automatic[df$Automatic == 0] <- NA","YOUR NAME" +"1474524532331","df$Mfr_Guarantee[df$Mfr_Guarantee == 0] <- NA","YOUR NAME" +"1474524532333","df$BOVAG_Guarantee[df$BOVAG_Guarantee == 0] <- NA","YOUR NAME" +"1474524532334","df$ABS[df$ABS == 0] <- NA","YOUR NAME" +"1474524532336","summary(myData)","YOUR NAME" +"1474524546570","str(myData)","YOUR NAME" +"1474524546575","summary(myData)","YOUR NAME" +"1474524586915","df$Automatic[df$Automatic == 0] <- NA","YOUR NAME" +"1474524815885","data[data==""0""]<-NA","YOUR NAME" +"1474524815913","df","YOUR NAME" +"1474524831304","data[data==""0""]<-NA","YOUR NAME" +"1474524831359","data","YOUR NAME" +"1474525219851","data[data==""0""]<-NA","YOUR NAME" +"1474525219867","data","YOUR NAME" +"1474525220150","","YOUR NAME" +"1474525220153","","YOUR NAME" +"1474525220156","","YOUR NAME" +"1474525220159","","YOUR NAME" +"1474525220160","summary(myData)","YOUR NAME" +"1474525251324","str(myData)","YOUR NAME" +"1474525251329","head(myData)","YOUR NAME" +"1474525251332","summary(myData)","YOUR NAME" +"1474525261006","myData1 <- na.exclude(myData)","YOUR NAME" +"1474525261008","str(myData1)","YOUR NAME" +"1474525261013","library(mice)","YOUR NAME" +"1474525261015","md.pattern(myData)","YOUR NAME" +"1474525466622","getwd()","YOUR NAME" +"1474525466624","data = read.csv(file=""C","YOUR NAME" +"/Users/Nino Zhang/Downloads/ToyotaPrices.csv"")","","YOUR NAME" +"1474525466648","set.seed(123)","YOUR NAME" +"1474525466651","n <- 100","YOUR NAME" +"1474525466654","beta_0 <- 10","YOUR NAME" +"1474525466656","beta_1 <- 2","YOUR NAME" +"1474525466657","mu <- 0","YOUR NAME" +"1474525466659","st_dev <- 0.7","YOUR NAME" +"1474525466660","err <- rnorm(n, mean = mu, sd = st_dev)","YOUR NAME" +"1474525466662","x_obs <- runif(n, min = 0, max = 1)","YOUR NAME" +"1474525466663","y_obs <- beta_0 + beta_1*x_obs + err","YOUR NAME" +"1474525466664","myData <- data.frame(err, x_obs, y_obs)","YOUR NAME" +"1474525466666","head(myData)","YOUR NAME" +"1474525466669","summary(myData)","YOUR NAME" +"1474525466673","str(myData)","YOUR NAME" +"1474525466678","summary(myData)","YOUR NAME" +"1474525466682","data[data==""0""]<-NA","YOUR NAME" +"1474525466705","data","YOUR NAME" +"1474525466996","","YOUR NAME" +"1474525466997","","YOUR NAME" +"1474525466998","","YOUR NAME" +"1474525466999","","YOUR NAME" +"1474525467000","summary(myData)","YOUR NAME" +"1474525467004","str(myData)","YOUR NAME" +"1474525467009","head(myData)","YOUR NAME" +"1474525467012","summary(myData)","YOUR NAME" +"1474525467017","myData1 <- na.exclude(myData)","YOUR NAME" +"1474525485420","myData1 <- na.exclude(myData)","YOUR NAME" +"1474525485422","str(myData1)","YOUR NAME" +"1474525492764","library(mice)","YOUR NAME" +"1474525552489","imp <- mice(myData, seed = 23109)","YOUR NAME" +"1474525705743","require(mice, character.only = TRUE)","YOUR NAME" +"1474525727900","require(""mice"""", character.only = TRUE)","YOUR NAME" +"1474525812469","require(mice"""", character.only = TRUE)","YOUR NAME" +"1474525823214","require(""mice"""", character.only = TRUE)","YOUR NAME" +"1474525877994","require(mice)","YOUR NAME" +"1474525887108","md.pattern(myData)","YOUR NAME" +"1474525887112","imp <- mice(myData, seed = 23109)","YOUR NAME" +"1474525887115","imp","YOUR NAME" +"1474525906775","str(myData1)","YOUR NAME" +"1474526080489","1 + 1","YOUR NAME" +"1474526186778","getwd()","YOUR NAME" +"1474526186782","data <- read.csv(""C","YOUR NAME" +"/Users/Nino Zhang/Downloads/ToyotaPrices.csv"")","","YOUR NAME" +"1474526197517","getwd()","YOUR NAME" +"1474526197520","data <- read.csv(""C","YOUR NAME" +"/Users/Nino Zhang/Downloads/ToyotaPrices.csv"")","","YOUR NAME" +"1474526197542","set.seed(123)","YOUR NAME" +"1474526197545","n <- 100","YOUR NAME" +"1474526197546","beta_0 <- 10","YOUR NAME" +"1474526197547","beta_1 <- 2","YOUR NAME" +"1474526197548","mu <- 0","YOUR NAME" +"1474526197549","st_dev <- 0.7","YOUR NAME" +"1474526197550","err <- rnorm(n, mean = mu, sd = st_dev)","YOUR NAME" +"1474526197552","x_obs <- runif(n, min = 0, max = 1)","YOUR NAME" +"1474526197553","y_obs <- beta_0 + beta_1*x_obs + err","YOUR NAME" +"1474526197555","myData <- data.frame(err, x_obs, y_obs)","YOUR NAME" +"1474526197558","head(myData)","YOUR NAME" +"1474526197566","summary(myData","YOUR NAME" +"1474526206382","getwd()","YOUR NAME" +"1474526206383","data <- read.csv(""C","YOUR NAME" +"/Users/Nino Zhang/Downloads/ToyotaPrices.csv"")","","YOUR NAME" +"1474526206403","set.seed(123)","YOUR NAME" +"1474526206404","n <- 100","YOUR NAME" +"1474526206405","beta_0 <- 10","YOUR NAME" +"1474526206406","beta_1 <- 2","YOUR NAME" +"1474526206407","mu <- 0","YOUR NAME" +"1474526206408","st_dev <- 0.7","YOUR NAME" +"1474526206408","err <- rnorm(n, mean = mu, sd = st_dev)","YOUR NAME" +"1474526206409","x_obs <- runif(n, min = 0, max = 1)","YOUR NAME" +"1474526206410","y_obs <- beta_0 + beta_1*x_obs + err","YOUR NAME" +"1474526206412","myData <- data.frame(err, x_obs, y_obs)","YOUR NAME" +"1474526206413","head(myData)","YOUR NAME" +"1474526206416","summary(myData)","YOUR NAME" +"1474526206423","str(myData)","YOUR NAME" +"1474526206428","summary(myData)","YOUR NAME" +"1474526206432","data[data==""0""]<-NA","YOUR NAME" +"1474526206457","data","YOUR NAME" +"1474526206738","summary(myData)","YOUR NAME" +"1474526206742","str(myData)","YOUR NAME" +"1474526206747","head(myData)","YOUR NAME" +"1474526206751","summary(myData)","YOUR NAME" +"1474526206756","myData1 <- na.exclude(myData)","YOUR NAME" +"1474526206758","myData1","YOUR NAME" +"1474526206773","str(myData1)","YOUR NAME" +"1474526225422","library(mice)","YOUR NAME" +"1474526564108","library(mice);","YOUR NAME" +"1474558433990","install.packages(""swirl"")","YOUR NAME" +"1474558459035","library(swirl)","YOUR NAME" +"1474558472344","swirl()","YOUR NAME" +"1474558614133","swirl()","YOUR NAME" +"1474558970865","swirl()","YOUR NAME" +"1474559032776","H <-read.table(""~/.rstudio-desktop/history_database"", sep= ","YOUR NAME" +""", fill=T, stringsAsFactors=F) names(H) <- c(""time"", ""answer"")","","YOUR NAME" +"1474559032779","H$id <- ""YOUR NAME""","YOUR NAME" +"1474559032782","write.csv(H, file = ""lesson1.csv"", row.names = FALSE)","YOUR NAME" +"1474559406342","H = read.table(""~/.C","YOUR NAME" +"\Users\Nino Zhang\AppData\Local\RStudio-Desktop/history_database"", sep=""",""", fill=T, stringAsFactors=F)","YOUR NAME" +"1474559438741","H = read.table(""~/.C","YOUR NAME" +"/Users/Nino Zhang/AppData/Local/Studio-Desktop/history_database"", sep=""",""", fill=T, stringAsFactors=F)","YOUR NAME" +"1474559576883","H = read.table(""~/.C","YOUR NAME" +"/Users/Nino Zhang/AppData/Local/RStudio-Desktop/history_database"", sep=""",""", fill=T, stringAsFactors=F)","YOUR NAME" +"1474559591912","H = read.table(""~/.C","YOUR NAME" +"/Users/Nino Zhang/AppData/Local/RStudio-Desktop/history_database"", sep=""",""", fill=T, stringsAsFactors=F)","YOUR NAME" +"1474559626054","swirl()","YOUR NAME" +"1474559657365","H <-read.table(""~/.rstudio-desktop/history_database"", sep=""","YOUR NAME" +""", fill=T, stringsAsFactors=F)","","YOUR NAME" +"1474559725842","H <-read.table(""C","YOUR NAME" +"/Users/Nino Zhang/Documents/.rstudio-desktop/history_database"", sep=""",""", fill=T, stringsAsFactors=F)","YOUR NAME" +"1474559814175","swirl()","YOUR NAME" +"1474559832151","bye()","YOUR NAME" +"1474559890116","H <-read.table(""C","YOUR NAME" +"/Users/Nino Zhang/AppData/Local/RStudio-Desktop/history_database"", sep=""",""", fill=T, stringsAsFactors=F)","YOUR NAME" +"1474559934778","H <-read.table(""C","YOUR NAME" +"/Users/Nino Zhang/AppData/Local/RStudio-Desktop/history_database"", sep=""",""", fill=T)","YOUR NAME" +"1474559940399","H <-read.table(""C","YOUR NAME" +"/Users/Nino Zhang/AppData/Local/RStudio-Desktop/history_database"", sep=""",""", fill=T, stringsAsFactors=F)","YOUR NAME" +"1474559997037","H <-read.table(""C","YOUR NAME" +"/Users/Nino Zhang/AppData/Local/RStudio-Desktop/history_database"", sep=""",""", fill=T, stringsAsFactors=False)","YOUR NAME" +"1474560025968","H <-read.table(""C","YOUR NAME" +"/Users/Nino Zhang/AppData/Local/RStudio-Desktop/history_database"", sep=""",""", fill=T, stringsAsFactors=False)","YOUR NAME" +"1474560040381","H <-read.table(""C","YOUR NAME" +"/Users/Nino Zhang/AppData/Local/RStudio-Desktop/history_database"", quote="""",sep=""",""", fill=T, stringsAsFactors=F)","YOUR NAME"