#Intro Stuff library(MASS) library(gmodels) library(dplyr) library(ggplot2) #T-test/ANOVA Example: head(cabbages) #normality hist(cabbages$HeadWt, col="green") qqnorm(cabbages$HeadWt, col="green", pch=16) qqline(cabbages$HeadWt) #homogeneity of variance boxplot(cabbages$HeadWt ~ cabbages$Cult, ylab="Head Weight", xlab="Cultivar", col="green") var_c39 <- var(cabbages$HeadWt[cabbages$Cult=='c39']) var_c52 <- var(cabbages$HeadWt[cabbages$Cult=='c52']) var_c39 var_c52 var_c52/var_c39 #Regression Example head(airquality) airquality2 <-na.omit(airquality) #linearity and homoscedacitiy plot(airquality2$Solar.R, airquality2$Ozone) plot(airquality2$Wind, airquality2$Ozone) plot(airquality2$Temp, airquality2$Ozone) lm1 <-lm(Ozone~Solar.R + Wind + Temp, data=airquality2) plot(lm1) #multicollinearity airqualityX <- (airquality2[,2:4]) cor(airqualityX) #Chi-square example Titanic2 <- Titanic[,,2,2] #adults who survived by class and sex Expected_M <-sum(Titanic2[1:4,1])/length(Titanic2[1:4,1]) Expected_F <-sum(Titanic2[1:4,2])/length(Titanic2[1:4,2]) Expected_M #84.5 Expected_F #79