Skip to content

Instantly share code, notes, and snippets.

@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")
@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 / 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 / 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 / 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 / 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 / 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 / custom.css
Last active April 15, 2017 22:52
Jupyter Notebook CSS: ~/.jupyter/custom/custom.css
.container {
width:100% !important;
}
@ggada
ggada / ipython_config.py
Last active June 26, 2018 10:24
IPython configuration: ~/.ipython/profile_default/ipython_config.py
c = get_config()
# Show any variable that stands on its own line
c.InteractiveShell.ast_node_interactivity = "all"
# Inline matplotlib plotting please
c.InteractiveShellApp.matplotlib = "inline"
# Retina screen, so better resolution please
c.InlineBackend.figure_format = 'retina'
@ggada
ggada / notebook.json
Last active June 17, 2022 06:16
Jupyter notebook.json: ~/.jupyter/nbconfig/notebook.json
{
"kse_rebinds": {
"edit": [],
"command": [
{
"to": ";",
"action_name": "jupyter-notebook:run-all-cells-above"
}
]
},