# Options # Surpress scientific notations, digits and lines options(scipen=999, digits=10, max.print=99999999) # Assignment 1 attach(DELL_DATA_cleaned) library(psych) summary(DELL_DATA_cleaned) describe(DELL_DATA_cleaned) library(naniar) vis_miss(DELL_DATA_cleaned) # Chisquare Tests prop.table(table(q14)) chisq.test(table(q14), p=c(0.55,0.45)) chisq.test(q13, SAMPLE, correct=FALSE) E<-chisq.test(q13, SAMPLE, correct=FALSE) str(E) E$expected chisq.test(q13, SAMPLE, correct=FALSE, simulate.p.value=TRUE, B=10000) fisher.test(table(q13,SAMPLE), workspace=2000000) library(vcd) assocstats(table(q13,SAMPLE)) # Paired t test t.test(q5, q4, paired=TRUE, alternative = "greater") # Nonpar: Wilcoxon wilcox.test(q5,q4, paired=TRUE, exact=FALSE, correct=FALSE) library(coin) wilcoxsign_test(q5 ~ q4, zero.method="Wilcoxon", distribution="asymptotic") # Oneway ANOVA # Type III === SPSS # To get SPSS equivalent SPSS results options(contrasts=c("contr.sum", "contr.poly")) FIT.01<- aov(q6 ~ factor(q11), data=DELL_DATA_cleaned) summary(FIT.01) drop1(FIT.01,~.,test="F") print(model.tables(FIT.01,"means"),digits=10) library(car) Anova(FIT.01, type=3) TukeyHSD(FIT.01) # DELL Experiment FIT.02<- aov(ATT ~ OL + factor(BRAND)*factor(PRODUCT), data=DELL_EXP) summary(FIT.02) Anova(FIT.02, type=3) # Plots plot(FIT.02) attach(DELL_EXP) interaction.plot(factor(BRAND),factor(PRODUCT),ATT) FIT.03<- lm(ATT ~ OL + factor(BRAND)*factor(PRODUCT), data=DELL_EXP) summary(FIT.03)