class(treatment) # Run a t-test comparing the math scores of students between the treatment and control group #http://www.statmethods.net/stats/ttest.html # command: t.test(x~y) where y is numeric variable of interest and x is dichotomous grouping variable t.test(math.score~treatment, var.equal=TRUE) # This is the result when equal variances can be assumed t.test(math.score~treatment) # This does Welch's correction for unequal variances #ANOVA # Conduct a one-way ANOVA to compare the math scores across the four classrooms #http://www.statmethods.net/stats/anova.html #Need to make sure that classroom is "factor" class(classroom) classroom <- as.factor(classroom) # command: "aov," stands for "analysis of variance" anova.fit <- aov(math.score~classroom) #to get the summary table summary(anova.fit) #post hoc with Bonferroni correction # http://statistics.ats.ucla.edu/stat/r/faq/posthoc.htm pairwise.t.test(math.score, classroom, p.adj="bonf")
class(treatment) # Run a t-test comparing the math scores of students between the treatment and control group #http://www.statmethods.net/stats/ttest.html # command: t.test(x~y) where y is numeric variable of interest and x is dichotomous grouping variable t.test(math.score~treatment, var.equal=TRUE) # This is the result when equal variances can be assumed t.test(math.score~treatment) # This does Welch's correction for unequal variances #ANOVA # Conduct a one-way ANOVA to compare the math scores across the four classrooms #http://www.statmethods.net/stats/anova.html #Need to make sure that classroom is "factor" class(classroom) classroom <- as.factor(classroom) # command: "aov," stands for "analysis of variance" anova.fit <- aov(math.score~classroom) #to get the summary table summary(anova.fit) #post hoc with Bonferroni correction # http://statistics.ats.ucla.edu/stat/r/faq/posthoc.htm pairwise.t.test(math.score, classroom, p.adj="bonf")
Introduction%20to%20R.docx