msbernst — Sep 17, 2014, 8:39 PM
library(car)
Loading required package: MASS Loading required package: nnet
library(ggplot2)
setwd('~/Downloads/')
results <- read.csv("finalData.csv", col.names = c('web', 'ground', 'type'))
# ggplot is awesome graphing library
# aes (aesthetics) tells you what goes on the x or y axis
# scale_x and scale_y set the limits
# coord_fixed makes sure it's a square aspect ratio
# TODO: add axis labels, clarify everything is %s
plot <- ggplot(results, aes(x=web, y=ground)) + geom_point() + scale_x_continuous(limits=c(0,100)) + scale_y_continuous(limits=c(0,100)) + coord_fixed() + scale_colour_brewer(type="qual", palette="Accent")
plot
# add loess smoothed fit curve (not for paper, more for interest)
# notice it's almost linear
plot + geom_smooth(method=lm)
# add line of best fit
plot + geom_smooth(method=lm)
# add x=y
plot + geom_abline(intercept = 0, slope = 1, colour="black", linetype="dotted") + annotate("text", x=90, y=93, label="web = ground", angle=45, colour="#666666")
# color by type
plot + geom_point(aes(color=type))
# eventually, save it using ggsave (not shown)
# do plot + everything you want
dmLM <- lm(ground ~ web, data=results)
linearHypothesis(dmLM, c("web = 1"))
Linear hypothesis test
Hypothesis:
web = 1
Model 1: restricted model
Model 2: ground ~ web
Res.Df RSS Df Sum of Sq F Pr(>F)
1 73 28256
2 72 12896 1 15360 85.8 6.9e-14 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1