Skip to content

Instantly share code, notes, and snippets.

@ggada
ggada / jupyter-show-all.py
Created April 10, 2017 01:09
Show me all the output
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
@ggada
ggada / lm-02.R
Created February 13, 2017 19:37
Linear regression line - ggplot2
ggplot(height, aes(x=fheight, y=sheight)) +
geom_point(size=0.2) +
stat_smooth(method = lm) +
xlab("Father's height") +
ylab("Son's height") +
ggtitle("Son's height vs. Father's height") +
theme(plot.title = element_text(hjust = 0.5))
@ggada
ggada / lm-01.R
Last active February 13, 2017 19:36
Linear regression line - GXY
plot(height,
main = "Son height vs. Father height",
xlab = "Father height",
ylab = "Son height")
abline(lm(height$sheight ~ height$fheight, data = height))
@ggada
ggada / scatter-02.R
Last active February 13, 2017 11:38
Residual scatter plot - ggplot2
ggplot(height, aes(height$fheight, mod$residuals)) +
geom_point(size=0.5) +
ggtitle("Residual plot of estimates") +
theme(plot.title = element_text(hjust = 0.5)) +
xlab("Father height") +
ylab("Son height")
@ggada
ggada / scatter-01.R
Last active February 13, 2017 10:28
Residual scatter plot - GXY
plot(height$fheight, resid(mod),
main = "Residual plot of estimates",
xlab = "Father height",
ylab = "Residual of son height estimate")
@ggada
ggada / density-01.R
Last active February 13, 2017 10:29
Plotting residual densities - GXY
plot(density(resid(mod)),
main = "Density plot of residuals")
@ggada
ggada / density-02.R
Last active February 13, 2017 10:29
Plotting residual densities - ggplot2
ggplot(mod, aes(x=mod$residuals)) +
geom_density(fill="blue", colour=NA, alpha=.2) +
geom_line(stat = "density") +
expand_limits(y = 0) +
ggtitle("Density plot of residuals") +
theme(plot.title = element_text(hjust = 0.5)) +
xlab("Residual") +
ylab("Density")