Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- hod2 <- count(deaths, c("hod", "cod"))
- hod2 <- subset(hod2, !is.na(hod))
- hod2 <- join(hod2, codes, by = "cod")
- hod2 <- ddply(hod2, "cod", transform, prop = freq / sum(freq))
- overall <- ddply(hod2, "hod", summarise, freq_all = sum(freq))
- overall <- transform(overall, prop_all = freq_all / sum(freq_all))
- hod2 <- join(hod2, overall, by = "hod")
- devi <- ddply(hod2, "cod", summarise, n = sum(freq),
- dist = mean((prop - prop_all)^2))
- devi <- subset(devi, n > 50)
- ggplot(data = devi, aes(x = n, y = dist)) + geom_point()
- last_plot() + scale_x_log10() + scale_y_log10() +
- geom_smooth(method = "rlm", se = FALSE)
- ggsave("n-dist-resid.pdf", width = 6, height = 6)
- devi$resid <- resid(rlm(log(dist) ~ log(n), data = devi))
- unusual <- subset(devi, resid > 1.5)
- hod_unusual <- match_df(hod2, unusual)
- ggplot(hod_unusual_big, aes(hod, prop)) +
- geom_line(aes(y = prop_all),
- data = overall, colour = "grey50") +
- geom_line() +
- facet_wrap(~ disease, ncol = 3)
- ggsave("unusual-big.pdf", width = 8, height = 6)
- last_plot() %+% hod_unusual_sml
- ggsave("unusual-sml.pdf", width = 8, height = 4)
Add Comment
Please, Sign In to add comment